My java solution


  • 0
    C
          public class Solution {
      public int arrangeCoins(int n) {
        if(n == 0)
        return 0;
        int index= 1;
        if(n == 1)
            return 1;
    	while(n>=index)
    	{
    		n=n-index;
    		index++;
    	}
    
    	return index-1;
    }
    

    }


Log in to reply
 

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