Skip to content

Commit 693d6a3

Browse files
authored
Merge pull request neetcode-gh#1234 from UdayGarg/441-Arranging-Coin
Create: 441-Arranging-Coin.py
2 parents 2eec026 + c09d7cd commit 693d6a3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

python/441-Arranging-Coin.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def arrangeCoins(self, n: int) -> int:
3+
l, r = 1, n
4+
res = 0
5+
while l <=r:
6+
mid = (l+r)//2
7+
coins = (mid /2) * (mid+1)
8+
if coins > n:
9+
r = mid - 1
10+
else:
11+
l = mid + 1
12+
res = max(mid, res)
13+
return res

0 commit comments

Comments
 (0)