My JavaScript solution!


  • 0
    W
    var arrangeCoins = function(n) {
        var count = 0;
        var i=1;
        while(1){
            if(n-i>=0){
                count++;
                n -= i;
                i++;
            }
            else return count;
        }
    };
    

Log in to reply
 

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