Leetcode Problem 1953. Maximum Number of Weeks for Which You Can Work

1953. Maximum Number of Weeks for Which You Can Work

Leetcode Solutions

Greedy Approach with Maximum Element Check

  1. Calculate the sum of all milestones.
  2. Find the maximum milestone count among all projects.
  3. If the maximum milestone count is greater than the sum of the other milestones, the maximum number of weeks you can work is 2 * (sum - max) + 1.
  4. Otherwise, you can work for a total of sum weeks, as you will be able to finish all milestones by alternating between projects.
UML Thumbnail

Simulation with Priority Queue

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...