You are given a set [1..n] represented as an array where one number is duplicated and one number is missing. Index placement exposes the mismatch directly because one value takes another value’s rightful slot.
nums = array with one duplicate and one missing value
array [duplicate, missing]
Example 1:
Input:
nums = [1,2,2,4]
Output:
[2,3]
Explanation:
2 is duplicated and 3 is missing.
Example 2:
Input:
nums = [1,1]
Output:
[1,2]
Explanation:
1 is duplicated and 2 is missing.