You are given an array nums that originally should contain every number from 1 to n exactly once.
However, due to an error:
One number appears two times
One number is missing
Your task is to figure out:
Which number appeared twice
Which number is missing
Return them as an array:
[duplicate, missing]
Input: nums = [3,1,2,5,3]
Output: [3,4]
Explanation:
The number 3 appears twice and 4 does not appear.
Input: nums = [2,2]
Output: [2,1]
Explanation:
The set should be {1,2}, but 2 appears twice and 1 is missing.
Accepted:
Submission: