Problem Challenge 1

Find the Corrupt Pair (easy) #

We are given an unsorted array containing ‘n’ numbers taken from the range 1 to ‘n’. The array originally contained all the numbers from 1 to ‘n’, but due to a data error, one of the numbers got duplicated which also resulted in one number going missing. Find both these numbers.

Example 1:

Input: [3, 1, 2, 5, 2]
Output: [2, 4]
Explanation: '2' is duplicated and '4' is missing.

Example 2:

Input: [3, 1, 2, 3, 6, 4]
Output: [3, 5]
Explanation: '3' is duplicated and '5' is missing.

Try it yourself #

Try solving this question here:

0 of 2 Tests Passed
ResultInputExpected OutputActual OutputReason
findNumbers([3,1,2,5,2])[2,4][-1,-1]Incorrect Output
findNumbers([3,1,2,3,6,4])[3,5][-1,-1]Incorrect Output
1.423s
Mark as Completed
←    Back
Find all Duplicate Numbers (easy)
Next    →
Solution Review: Problem Challenge 1