Leaderboard
Showing:
Completing tasks
Easy Accuracy: 77.0% Submissions: 331 Points: 2

There are total n tasks given to a group of 5 students in a class. Three of those five students completed m tasks of their choices and left the group. Now the burden of completing remaining tasks is on the two students Tanya and Manya. Suppose the n tasks are in an array form 1,2,3,...n. Tanya and Manya decided to complete their remaining tasks in the following manner :- First of the remaining task is done by Tanya and the next remaining one by Manya . For example if = 10 and = 4 and the completed 4 tasks are {2, 3, 5, 7} then the reamining tasks are {1, 4, 6, 8, 9, 10} so, Tanya completes {1, 6, 9} tasks and Manya completes {4, 8, 10} tasks and thereby completing the n tasks given.

Given n, m and the indexes (1 for first task, 2 for second task and so on..) of completed tasks, find the tasks which Tanya and Manya have to complete.

Example 1:

Input:
n = 15, m = 6
arr[] = {2, 5, 6, 7, 9, 4}
Output: 
1 8 11 13 15 
3 10 12 14 
Explanation: The remaining tasks are :
{1, 3, 8, 10, 11, 12, 13, 14, 15}.
So Tanya should take these tasks :
{1, 8, 11, 13, 15}.
And Manya should take these tasks :
{3, 10, 12, 14}.

Example 2:

Input:
n = 4, m = 3
arr[] = {2, 4, 3}
Output: 
1

Explanation: There are no task for Manya.

Your Task:
You don't need to read input or print anything. Your task is to complete the function findTasks() which takes the array of integers arr, m and as parameters and returns a pair of an array of integers denoting the answer.

Expected Time Complexity: O(n)
Expected Auxiliary Space: O(n)

Constraints:
1 ≤ m ≤ n ≤ 105
1 ≤ arr[i] ≤ n

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Completing tasks

Output Window