Skip to content

Commit 0232022

Browse files
Merge pull request #3048 from benmak11/343
Create 0343-integer-break.java
2 parents a1113e2 + e2cfad6 commit 0232022

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: java/0343-integer-break.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int integerBreak(int n) {
3+
if (n < 4) return n - 1;
4+
5+
int res = 1;
6+
7+
while (n > 4) {
8+
n -= 3;
9+
res *= 3;
10+
}
11+
12+
res *= n;
13+
return res;
14+
}
15+
}

0 commit comments

Comments
 (0)