Set Mismatch Finder

You have an array nums of length n that should contain every integer from 1 to n exactly once, except that one value appears twice and one value is missing. Return [duplicate, missing]: the value that appears twice, followed by the value in [1, n] that never appears. You may modify nums.

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

Set Mismatch Finder

You have an array `nums` of length `n` that should contain every integer from `1` to `n` exactly once, except that one value appears twice and one value is missing. Return `[duplicate, missing]`: the value that appears twice, followed by the value in `[1, n]` that never appears. You may modify `nums`.