In this problem ,the given length of an array is N, but the actual length of an array is N+2. Because two elements are missing from an array.An array having natural number sequence in which two numbers are missing from that sequence.So, in this problem we have to calculate those values.

Example:

Input  : arr[] = {1, 3, 5, 6}

Output : 2 4

Input  : arr[] = {1, 2,5}

Output : 3,4

There are following steps to solve this problem:

1.Let's create an array result  that mark about the presence of an existing element in an array .

Given array length is N ,but the original array length is N+2 and the length of result array will be (N+2)+1.

2.Traverse an original array and placed 1 in result array , at those indexes where   the element is present,i.e, result[i] = 1;

3. Then ,print all the missing values ,check if result[i]==0 ,then print i.

Code for this problem :

Output:

Time Complexity of this approach is O(n), where n is the number of elements in the array.