Java basic solution


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

Log in to reply
 

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