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
Be the first one to answer
Add answer anonymously...
Top Optum Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Optum Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app