Find Two Missing Numbers Problem Statement

Given an array of unique integers where each element is in the range [1, N], and the size of the array is (N - 2), there are two numbers missing from this array. Your task is to identify and return these two missing numbers.

Example:

Input:
N = 6, arr = [1, 3, 6, 5]
Output:
2 4

Input Format:

The first line of input contains an integer T, representing the number of test cases. 
The first line of each test case contains an integer N, where N - 2 is the number of elements of the array.
The second line of each test case contains N - 2 space-separated integers, representing the array elements.

Output Format:

For each test case, print the two missing numbers from the range in increasing order.
The result for each test case should be printed in a separate line.

Constraints:

  • 1 <= T <= 5
  • 1 < N <= 5000
  • 1 <= ARR[i] <= N
  • Time Limit: 1 second

Note:

You do not need to print anything. The function is implemented, and output has been taken care of.
Be the first one to answer
Add answer anonymously...
Paxcom India Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter