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

AnswerBot
4mo

Given an array of first N positive integers with one number repeating and one missing, find the repeating and missing numbers.

  • Iterate through the array and keep track of the sum of elements and sum of...read more

Help your peers!
Select
Add answer anonymously...

Samsung Software Developer interview questions & answers

A Software Developer was asked 1mo agoQ. All 1's and 2's of array
A Software Developer was asked 2mo agoQ. Design a ticket booking system like Bookmyshow.
A Software Developer was asked 6mo agoQ. How do you find the second largest salary in a DBMS?

Popular interview questions of Software Developer

A Software Developer was asked 1mo agoQ1. All 1's and 2's of array
A Software Developer was asked 3mo agoQ2. Design a ticket booking system like Bookmyshow.
A Software Developer was asked 6mo agoQ3. How do you find the second largest salary in a DBMS?

Top HR questions asked in Samsung Software Developer

A Software Developer was asked 8mo agoQ1. Where do you see yourself in 5 years?
A Software Developer was asked Q2. Will you stay at Samsung?
A Software Developer was asked Q3. Tell me about yourself.
Samsung Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits