Easy · 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
Core interview problems are free with a full runner and lessons; Pro opens the complete library.