Mismatch Array
ARRAY
Problem
Given an array nums
containing n
numbers taken from the range 1 to n
, it is known that one number from the set {1, 2, ..., n}
is missing and one number appears twice in nums
.
Return these two numbers in the form of an array.
Examples
findErrorNums([5, 3, 2, 7, 6, 6, 1, 4]) // returns [6, 8] // The number 6 is duplicated and the item 8 is missing. findErrorNums([2, 3, 3, 4, 5, 6, 7, 8, 9, 10]) // returns [3, 1] // The number represented by 3 appears twice // while the item 1 is absent.
Loading...
Loading...Loading...