Skip to content

Commit 01bbf09

Browse files
authored
Create maximum-number-of-weeks-for-which-you-can-work.py
1 parent ee5d163 commit 01bbf09

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def numberOfWeeks(self, milestones):
6+
"""
7+
:type milestones: List[int]
8+
:rtype: int
9+
"""
10+
total, max_num = sum(milestones), max(milestones)
11+
return min((total-max_num)+((total-max_num)+1), total)

0 commit comments

Comments
 (0)