2084. Maximum Number of Weeks for Which You Can Work
My accepted Python solution to LeetCode problem 2084, Maximum Number of Weeks for Which You Can Work, running in 7ms.
- Difficulty: Medium
- Python
- Runtime 7ms
- Memory 28.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 7ms, memory 28.3MB, accepted 2025-12-29.
class Solution:
def numberOfWeeks(self, milestones: List[int]) -> int:
total = sum(milestones)
max_val = max(milestones)
rest = total - max_val
# If max is greater than rest + 1, we can't finish all
if max_val > rest + 1:
return 2 * rest + 1
else:
return total