Description

Given an array nums representing a set from 1 to n with one number duplicated and one missing, return the duplicated number and the missing number.

Examples

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

2 is duplicated, 3 is missing.

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

3 appears twice in the array, so 3 is duplicated. The set should contain numbers 1 to 5, but 4 is missing.

Input:nums = [2,2]
Output:[2,1]
Explanation:

2 appears twice in the array, so 2 is duplicated. The set should contain numbers 1 to 2, but 1 is missing.

Constraints

  • 2 ≤ nums.length ≤ 10⁴
  • 1 ≤ nums[i] ≤ nums.length

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!