Java non-math solution (48ms)


  • 0
    J
        public int arrangeCoins(int n) 
        {
            int numRows = 0;
            
            while (n > numRows)
                n -= ++numRows;
    
            return numRows;
        }
    }
    
    By Jason B.

Log in to reply
 

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