Skip to content

Commit e02aa73

Browse files
authored
Create Solution.java
1 parent 23bad3b commit e02aa73

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int arrangeCoins(int n) {
3+
int l = 0, r = n;
4+
while (l < r) {
5+
int mid = l + r + 1 >>> 1;
6+
if (1L * mid * (mid + 1) / 2 <= n) l = mid;
7+
else r = mid - 1;
8+
}
9+
return r;
10+
}
11+
}

0 commit comments

Comments
 (0)