Math Fundamentals18 sections · 814 units
Open in Course

Problem - Set Mismatch

LeetCode 645

You have a set which originally contains numbers from 11 to nn. One number got duplicated to another number, making one number appear twice and one number missing.

Find the number that occurs twice and the number that is missing. Return them as [duplicate,missing][\text{duplicate}, \text{missing}].

For example, if the array is [1,2,2,4][1, 2, 2, 4], the answer is [2,3][2, 3] because 22 appears twice and 33 is missing.