simple solution for Javascript


  • 0
    F
    /**
     * @param {number} n
     * @return {number}
     */
    var arrangeCoins = function(n) {
        if(n==0) return 0;
        
        for(var i=1;;i++) {
            n-=i;
            if(n<=i) {
                return i;
            }
        }
    };
    

Log in to reply
 

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