Array Two Missing Numbers LeetCode

Given an array of n unique integers where each element in the array is in range [1, n]. The array has all distinct elements and size of array is (n-2). Hence Two numbers from the range are missing from this array. Find the two missing numbers.

Example 1:
  • Input  : arr[] = {1, 3, 5, 6}
  • Output : 2, 4
Example 2:
  • Input : arr[] = {1, 2, 4}
  • Output : 3, 5
Example 3:
  • Input : arr[] = {1, 2}
  • Output : 3, 4

This problem is popular in GeeksForGeeks, StackOverFlow, LeetCode A collection of hundreds of interview questions and solutions are available in our blog at Interview Question Solutions

Solution:

 

No comments:

Post a Comment