easy java solution

  • 0

    Just decrease the number deducting the iteration variable

    public int arrangeCoins(int n) {
           if(n==1) return 1;
           int count = 0;
           for(int i=1;i<=n;i++){
               if(n>=i) {
                   n -= i;
           return count;

Log in to reply

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