Member-only story
Find Missing Elements in an Array that are Present in Another Array| Coding Interview | Searching
4 min readOct 7, 2021
This is an easy problem and it has been asked by Zoho, Accolite, and Snapdeal.
For a better grasp of the problem, after reading each section, try to code that approach. If you get stuck 😉, you can always look at the commented code I have provided for your reference.
This problem is part of the 30 Days Preparation Plan.
Table of Contents
- Description
- Naive Solution (Brute)
- Code
- Time & Space Complexity
- Efficient Solution
- Code
- Time & Space Complexity
Description
Given two arrays, A and B, of sizes N and M, respectively. Print all those elements of A that are missing in array B.
Every element of the first array must be present in the second array; if not, you have to print those numbers.
Example 1:
Input: A = [1 6 4 0 2]
B = [6 3 4 5 0]
Output: [1 2]Explanation: Elements 1 and 2 of A are not present in B, hence the result is 1 and 2.Example 2:
Input: A = [9 8 7 6 5]
B = [1…