#2965
Find Missing and Repeated Values
newbie · 140 · lc easy +13 · verified · 83.2% accepted · 998 likes · top 95%
Description
An n x n integer matrix grid contains every integer from 1 to n2 except one number b is missing and one number a appears twice.
Return [a, b].
Example 1:
Input: grid = [[1,3],[2,2]]
Output: [2,4]
Explanation: Number 2 is repeated and number 4 is missing so the answer is [2,4].
Example 2:
Input: grid = [[9,1,7],[8,9,2],[3,4,6]]
Output: [9,5]
Explanation: Number 9 is repeated and number 5 is missing so the answer is [9,5].
Code
1
2
3