Simple java solution


  • 0
    V

    Keep decreasing the value of n until the condition is fulfilled

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

Log in to reply
 

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