Skip to content

Practice Maximum Number of Weeks for Which You Can Work

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1953
LeetCode Problem

Maximum Number of Weeks for Which You Can Work

Problem Statement

milestones[i] is the remaining milestone count of project i. Finish exactly one remaining project milestone each week without taking breaks, and never work on the same project in consecutive weeks. Stop when no legal next milestone exists or every project is complete. Return the maximum possible number of working weeks for milestones.

Source: Maximum Number of Weeks for Which You Can Work on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
milestones = [1,2,3]
Output
6

# Example 2

Input
milestones = [5,2,1]
Output
7

Constraints

n == milestones.length
1 <= n <= 10^5
1 <= milestones[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Maximum Number of Weeks for Which You Can Work.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.