n tags numbered 1 to n, each number exactly once. Because of a mistake, one tag was reprinted with the number of another tag. Now one number appears twice and another one is missing.
You are given the array tags with the numbers after the mistake, in any order. Return an array of two numbers: first the number that appears twice, then the number that is missing.tags=[1, 3, 3, 4] → [3, 2]
The tags should be 1, 2, 3, 4. Tag 3 shows up twice and tag 2 is gone.
tags=[2, 2] → [2, 1]
Out of tags 1 and 2, the 1 was replaced by a second 2.
tags=[5, 1, 4, 2, 1] → [1, 3]
Order does not matter: 1 is duplicated and 3 is missing.
n == tags.length ≤ 10⁵tags[i] ≤ ntags=[1, 3, 3, 4]
[3, 2]
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.