C++ Naive Solution


  • 0
    Y

    Easy to understand.

    class Solution {
    public:
    int arrangeCoins(int n) {

        int count=0;
        int left=n;
        while (left > count) {
            count++;
            left -= count;
        }
        return count;
        
    }
    

    };


Log in to reply
 

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