Medium · Arrays
Find duplicate and missing
Given an array nums of n integers whose values should be exactly 1..n, where one value appears twice and one value is missing, return [duplicate, missing].
Examples
Example 1
[1,2,2,4] → dup 2, miss 3Output: dup 2, missing 3
Example 2
[1,2,4,4,5] → dup 4, miss 3Output: dup 4, missing 3
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.