Skip to content

Commit 6784c4b

Browse files
authored
Create 1716. Calculate Money in Leetcode Bank 1 (#917)
2 parents e252fd1 + b8ca568 commit 6784c4b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int totalMoney(int n) {
4+
int sum = 0, i = 1, j = 0;
5+
for(int cnt = 1; cnt <= n; ++cnt)
6+
{
7+
sum += i;
8+
i++;
9+
if(i > 7+j)
10+
{
11+
j++;
12+
i = 1 + j;
13+
}
14+
}
15+
return sum;
16+
}
17+
};

0 commit comments

Comments
 (0)