We need to solve integer inequality `k * (k + 1) / 2 <= n < (k + 1) * (k + 2) / 2`

, thus we need to find integer solution of `k^2 + k - 2 * n == 0`

which has positive root `int((sqrt(8.0 * n + 1) - 1) / 2)`

.

```
class Solution {
public:
int arrangeCoins(int n) {
return (sqrt(8.0 * n + 1) - 1) / 2;
}
};
```