[c#] simple c# solution


  • 0
    N
        public int ArrangeCoins(int n) {
            for(var x = 0;x<=n;x++){
                var s = 0.5 *x*(x+1);
                if(s == n) {
                    return x;
                }
                else if(s>n){
                    return x-1;
                }
            }
            
            return 0;
        }
    

Log in to reply
 

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