441. Arranging Coins¶ Time: $O(1)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6class Solution { public: int arrangeCoins(long n) { return (-1 + sqrt(8 * n + 1)) / 2; } }; 1 2 3 4 5class Solution { public int arrangeCoins(long n) { return (int) (-1 + Math.sqrt(8 * n + 1)) / 2; } } 1 2 3class Solution: def arrangeCoins(self, n: int) -> int: return int((-1 + math.sqrt(8 * n + 1)) // 2)