Set Mismatch Finder

You have an array nums of length n where all integers are in [1, n] and each appears once or twice. Return [duplicate, missing] — the number that appears twice and the number that is missing from the range.

Examples
Input: [1,2,2,4]
Output: [2,3]
Hints

Set Mismatch Finder

You have an array nums of length n where all integers are in [1, n] and each appears once or twice. Return [duplicate, missing] — the number that appears twice and the number that is missing from the range.