Problem Statement could be found @https://leetcode.com/contest/11/problems/arranging-coins/
Code Snippet - Code, I believe, is self explainatory
class Solution {
public:
int arrangeCoins(int n) {
int i = 1;
if (n ==0)
return 0;
while ( (n-i) >=0){
n = n-i;
i++;
}
return (i-1);
}
};
Code Snippet - Code, I believe, is self explainatory
class Solution {
public:
int arrangeCoins(int n) {
int i = 1;
if (n ==0)
return 0;
while ( (n-i) >=0){
n = n-i;
i++;
}
return (i-1);
}
};
No comments:
Post a Comment