Skip to content
LC-1953 Medium LeetCode

1953. Maximum Number of Weeks for Which You Can Work

Read the full problem statement on LeetCode.
Difficulty: medium Acceptance: 41% Topics: Array, Greedy
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(1)

class Solution(object):
    def numberOfWeeks(self, milestones):
        """
        :type milestones: List[int]
        :rtype: int
        """
        total, max_num = sum(milestones), max(milestones)
        other_total = (total-max_num)
        return other_total+min(other_total+1, max_num)

Solution from kamyu104/LeetCode-Solutions · MIT

Similar questions