Find The Repeating And Missing Number Problem Statement

You are provided with an array nums which contains the first N positive integers. In this array, one integer appears twice, and one integer is missing. Your task is to identify the integer that repeats and the one that is missing.

Input:

The first line contains an integer 'T', the number of test cases. 
Each test case consists of two lines:
- An integer 'N', the number of elements in the array.
- 'N' space-separated integers, the elements of the array.

Output:

For each test case, output the repeating and missing numbers as two space-separated integers.

Example:

Input:
nums = [1, 2, 3, 4, 4, 5]
Output:
4 6
Explanation:

In the given array, the number '4' appears twice and the number '6' is missing.

Constraints:

  • 1 ≤ T ≤ 100
  • 2 ≤ N ≤ 104
  • 1 ≤ nums[i] ≤ N

Time Limit: 1 sec

Be the first one to answer
Add answer anonymously...
Samsung 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