Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6560 |

@blackshadows | 6400 |

@mb1973 | 5777 |

@Quandray | 5271 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4356 |

@sanjay05 | 3762 |

@mantu_singh | 3638 |

@gfgaccount | 3601 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@anish5256 | 991 |

@vimleshpratapsingh321 | 980 |

@skj7 | 871 |

@akhileshkumar562002 | 862 |

@pradeeppatidar1999 | 840 |

@kanewilliamson123 | 837 |

@pd420786 | 813 |

@infilooop | 800 |

@bunnybug320 | 796 |

@smitabose7826 | 784 |

@virgat | 768 |

Complete Leaderboard |

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}

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

...