Skip to content

Commit 3321a44

Browse files
committedJan 21, 2022
Add solution #1716
1 parent d9a7b03 commit 3321a44

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254
1668|[Maximum Repeating Substring](./1668-maximum-repeating-substring.js)|Easy|
255255
1669|[Merge In Between Linked Lists](./1669-merge-in-between-linked-lists.js)|Medium|
256256
1672|[Richest Customer Wealth](./1672-richest-customer-wealth.js)|Easy|
257+
1716|[Calculate Money in Leetcode Bank](./1716-calculate-money-in-leetcode-bank.js)|Easy|
257258
1748|[Sum of Unique Elements](./1748-sum-of-unique-elements.js)|Easy|
258259
1780|[Check if Number is a Sum of Powers of Three](./1780-check-if-number-is-a-sum-of-powers-of-three.js)|Medium|
259260
1832|[Check if the Sentence Is Pangram](./1832-check-if-the-sentence-is-pangram.js)|Easy|
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* 1716. Calculate Money in Leetcode Bank
3+
* https://leetcode.com/problems/calculate-money-in-leetcode-bank/
4+
* Difficulty: Easy
5+
*
6+
* Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.
7+
*
8+
* He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will
9+
* put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the
10+
* previous Monday. Given n, return the total amount of money he will have in the Leetcode bank at
11+
* the end of the nth day.
12+
*/
13+
14+
/**
15+
* @param {number} n
16+
* @return {number}
17+
*/
18+
var totalMoney = function(n) {
19+
let mondayCount = Math.floor(n / 7);
20+
let aggregate = (mondayCount ** 2 + 7 * mondayCount) / 2;
21+
let result = aggregate * 7;
22+
for (let i = 0; i < n - mondayCount * 7; i++) {
23+
result += mondayCount + i + 1;
24+
}
25+
return result;
26+
};

0 commit comments

Comments
 (0)
Please sign in to comment.