Back to course home
0% completed
Solution: Set Mismatch
Problem Statement
You are given an array nums
of size n
, originally containing 1
to n
integers. Unfortunately, due to some error
, one number got duplicated
, replacing
another number that now goes missing
from the sequence.
Identify the duplicated number
and the missing number
and return them as a pair
.
Examples
-
Example 1:
- Input: nums =
[1,3,3,4]
- Expected Output:
[3,2]
- Justification: Here,
3
appears twice, and2
is missing from the sequence.
- Input: nums =
-
Example 2:
- Input: nums =
[2,2,3,5,4]
- Expected Output:
- Input: nums =
.....
.....
.....
Like the course? Get enrolled and start learning!