[Java] Very Easy to Understand


  • 0
    J
    public class Solution {
        public int arrangeCoins(int n) {
           if(n == 0) return 0;
           int i = 1;
           while(true){
               n-=i;
               if(n<=i) break;
               i++;
           }
           return i;
       } 
    }
    

Log in to reply
 

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