We need the smallest x such that 1+2...+x is smaller than n. Therefore we need smallest x such that x(x+1)/2 <= n. Hence the closest guess for x is square root of 2*n. We test if it's good by plugging it in the original condition. If it is too big we substract 1.

```
public int arrangeCoins(int n) {
int x =(int) Math.sqrt(2L*n);
return x*(x+1L)<=2L*n? x : x-1;
}
```