LeetCode solutions

1817. Calculate Money in Leetcode Bank

My accepted Python solution to LeetCode problem 1817, Calculate Money in Leetcode Bank, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-30.

python
class Solution:
    def totalMoney(self, n: int) -> int:
        weeks = n // 7
        days = n % 7
        # Sum of complete weeks: each week adds 28, plus 7 more for each subsequent week
        total = weeks * 28 + 7 * weeks * (weeks - 1) // 2
        # Add remaining days
        start = weeks + 1
        for i in range(days):
            total += start + i
        return total

Source