JAVA - 3 lines - 42 ms


  • 0
    N
    public class Solution {
        public int arrangeCoins(int n) {
            long temp = n * 2l;
            long sqrt = (long) Math.sqrt(temp);
            return (int)(sqrt * (sqrt + 1) > temp ? sqrt - 1 : sqrt);
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.