Geeksforgeeks

X

DAYS

:

HOUR

:

MINS

:

SEC

Error

Copied to Clipboard

Given two arrays **A** and **B **contains integers of size **N** and **M**, the task is to find numbers which are present in the first array, but not present in the second array.

**Example 1:**

**Input: **N = 6, M = 5
A[] = {1, 2, 3, 4, 5, 10}
B[] = {2, 3, 1, 0, 5}
**Output:** 4 10
**Explanation**: 4 and 10 are present in
first array, but not in second array.

**Example 2:**

Input:N = 5, M = 5 A[] = {4, 3, 5, 9, 11} B[] = {4, 9, 3, 11, 10}Output:5Explanation: Second array does not contain element 5.

**Your Task:**

This is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function **findMissing**() that takes array** A, **array** B, **integer** N, **and integer** M ** as parameters and returns an array that contains the missing elements and the order of the elements should be the same as they are in array A.

**Expected Time Complexity:** O(N+M).

**Expected Auxiliary Space:** O(M).

**Constraints:**

1 ≤ N, M ≤ 10^{6}

-10^{6} ≤ A[i], B[i] ≤ 10^{6}

We are replacing the old Disqus forum with the new Discussions section given below.

Click here to view old Disqus comments.

Click here to view old Disqus comments.

Login to report an issue on this page.

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

YesLoading...

Find missing in second array

...