Skip to content

Commit 77eb444

Browse files
committed
Runtime: 9 ms (Top 33.5%) | Memory: 41.11 MB (Top 16.7%)
1 parent e18c36a commit 77eb444

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
// Runtime: 9 ms (Top 33.5%) | Memory: 41.11 MB (Top 16.7%)
2+
13
class Solution {
24
public String optimalDivision(int[] nums) {
3-
if(nums.length == 1){
5+
6+
if(nums.length==1){
47
return nums[0] + "";
5-
}
6-
if(nums.length == 2){
7-
StringBuilder sb = new StringBuilder();
8-
sb.append(nums[0]+"/"+nums[1]);
8+
}else if(nums.length==2){
9+
StringBuilder sb=new StringBuilder();
10+
sb.append(nums[0] + "/" + nums[1]);
911
return sb.toString();
1012
}
11-
StringBuilder sb = new StringBuilder();
12-
sb.append(nums[0]);
13-
sb.append("/(");
14-
for(int i = 1; i < nums.length -1; i++){
15-
sb.append(nums[i]+"/");
13+
14+
StringBuilder sb=new StringBuilder();
15+
sb.append(nums[0]);
16+
sb.append("/(");
17+
for(int i=1;i<nums.length-1;i++){
18+
sb.append(nums[i] + "/");
1619
}
17-
sb.append(nums[nums.length -1] +")");
20+
sb.append(nums[nums.length-1] + ")");
21+
1822
return sb.toString();
1923
}
20-
}
24+
}

0 commit comments

Comments
 (0)