Calculate Money in Leetcode Bank - Problem
Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.
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.
Given n, return the total amount of money he will have in the Leetcode bank at the end of the nth day.
Input & Output
Example 1 — Basic Case
$
Input:
n = 4
›
Output:
10
💡 Note:
Day 1 (Mon): $1, Day 2 (Tue): $2, Day 3 (Wed): $3, Day 4 (Thu): $4. Total: 1+2+3+4 = 10
Example 2 — Complete Week
$
Input:
n = 10
›
Output:
37
💡 Note:
Week 1: $1+$2+$3+$4+$5+$6+$7 = $28. Week 2 (3 days): $2+$3+$4 = $9. Total: 28+9 = 37
Example 3 — Single Day
$
Input:
n = 1
›
Output:
1
💡 Note:
Only Monday of first week: $1
Constraints
- 1 ≤ n ≤ 1000
Visualization
Tap to expand
Understanding the Visualization
1
Input
Number of days n
2
Pattern
Weekly deposits: Mon+1, Tue+1, ..., Sun+1, then next Monday+1
3
Output
Total money saved after n days
Key Takeaway
🎯 Key Insight: Each week follows the same pattern but with Monday amount incrementing by $1
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code