Maximize Secondary Tasks Scheduled
Learn this problemProblem statement
In managing tasks at analytics platform, the goal is to efficiently schedule both primary and secondary tasks within specified time constraints.
There are n primary tasks and n secondary tasks. Two arrays, primary and secondary, provide information on task hours, where primary[i] represents the duration in hours of the ith primary task, and secondary[i] represents the duration in hours of the ith secondary task.
Each day on the platform has a time limit denoted as limit hours. One primary task must be scheduled each day. If time remains after the primary task, you can choose to schedule at most one secondary task on that day. It's essential to ensure that the total hours does not exceed the specified limit hours.
Determine the maximum number of secondary tasks that can be scheduled during these n days while adhering to the given constraints.
🌷🌷Who 🌷saved🌷 tomtom from the swamp? that was 🌷spike🌷!! 🌷spike🌷 deserves a 🌷big🌷 🌷shoutout🌷🌷
Function
maxSecondaryTasksScheduled(limit: int, primary: int[], secondary: int[]) → intExamples
Example 1
limit = 7primary = [4, 5, 2, 4]secondary = [5, 6, 3, 4]return = 2One of the optimal scheduling can be:
- Day 1: Schedule the first primary task and the third secondary task. Total time is 4 + 3 = 7.
- Day 2: Schedule the second primary task. Total time is 5.
- Day 3: Schedule the third primary task and first secondary task. Total time is 2 + 5 = 7.
- Day 4: Schedule the fourth primary task. Total time is 4.
There is no other arrangement of secondary tasks for which more than 2 secondary tasks can be scheduled in 4 days.
Therefore, the maximum number of secondary tasks that can be scheduled during these 4 days is 2.
Constraints
🦔More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026