Minimum Days to Complete Work

You have 'N' tasks to complete. Each task can only be done on one of two specific days provided in two arrays: day1 and day2.

For each task i, day1[i] represents the earliest day task i can be done on array day1 and day2[i] represents the earliest day task i can be done on array day2. It is guaranteed that day2[i] < day1[i].

The tasks must be scheduled such that the completion days are in non-decreasing order from day1, and you need to determine the minimum number of days required to complete all tasks.

Example:

Input:
day1 = [5, 6, 2]  
day2 = [2, 4, 1]
Output:
4
Explanation:

Complete work 3 on day 1, work 1 on day 2, and work 2 on day 4. The completion order with respect to day1 is [2, 5, 6], which is non-decreasing, so the number of days required is 4.

Constraints:

  • 1 <= T <= 50
  • 0 <= N <= 10^3
  • 1 <= day1[i], day2[i] <= 10^9
  • Time Limit: 1 sec
AnswerBot
4mo

Find the minimum number of days required to complete all tasks given specific completion days for each task.

  • Sort the tasks based on day1 in ascending order.

  • For each task, choose the minimum of day1 an...read more

Help your peers!
Select
Add answer anonymously...

Optum Global Solutions Software Developer interview questions & answers

A Software Developer was asked 7mo agoQ. What is the difference between relational and non-relational DBMS?
A Software Developer was asked 10mo agoQ. Write code to implement debouncing.
A Software Developer was asked 10mo agoQ. What are closures in JavaScript?

Popular interview questions of Software Developer

A Software Developer was asked 6mo agoQ1. What is the difference between relational and non-relational DBMS?
A Software Developer was asked 10mo agoQ2. Write code to implement debouncing.
A Software Developer was asked 10mo agoQ3. What are closures in JavaScript?
Optum Global Solutions Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits