You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the i^th row has exactly i coins. The last row of the staircase may be incomplete.Given the integer n, return the number of complete rows of the staircase you will build.
from math import isqrtclass Solution: # Time: O(1) # Space: O(1) def arrange_coins(self, n: int) -> int: # largest k with k * (k + 1) / 2 <= n return (isqrt(8 * n + 1) - 1) // 2