1716. Calculate Money in Leetcode Bank Easy
1/**
2 * [1716] Calculate Money in Leetcode Bank
3 *
4 * Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.
5 * He starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the previous Monday.<span style="display: none;"> </span>
6 * Given n, return the total amount of money he will have in the Leetcode bank at the end of the n^th day.
7 *
8 * Example 1:
9 *
10 * Input: n = 4
11 * Output: 10
12 * Explanation: After the 4^th day, the total is 1 + 2 + 3 + 4 = 10.
13 *
14 * Example 2:
15 *
16 * Input: n = 10
17 * Output: 37
18 * Explanation: After the 10^th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2^nd Monday, Hercy only puts in $2.
19 *
20 * Example 3:
21 *
22 * Input: n = 20
23 * Output: 96
24 * Explanation: After the 20^th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96.
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= n <= 1000
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/calculate-money-in-leetcode-bank/
35// discuss: https://leetcode.com/problems/calculate-money-in-leetcode-bank/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn total_money(n: i32) -> i32 {
41 0
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_1716() {
53 }
54}
55
Back
© 2025 bowen.ge All Rights Reserved.