Set Mismatch

You are given an array nums representing [1,2,...,n] where one number is missing and one appears twice. Return [duplicate, missing].

Input Format

nums = array with one duplicate and one missing

Output Format

[duplicate, missing]

Constraints

  • 2 <= nums.length <= 10^4; 1 <= nums[i] <= nums.length

Examples

Example 1:

Input:

nums = [1,2,2,4]

Output:

[2,3]

Explanation:

2 appears twice and 3 is missing.

Loading...
Set Mismatch - Arrays DSA Problem