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
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
Top Optum Global Solutions Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Optum Global Solutions Software Developer
Reviews
Interviews
Salaries
Users/Month