Find Missing and Repeated Values Problem
Find Missing and Repeated Values Problem — ExecCode Easy DSA Practice
Solve the Find Missing and Repeated Values problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a 0-indexed 2D integer matrix grid of size n n with values in the range [1, n^2]. Your task is to the task is to find the repeating and missing numbers a and b. Each integer appears exactly once except a which appears twice and b which is missing. Return a 0-indexedinteger array ans of size 2 where ans[0] equals to a and ans[1] equals to b .
Examples
Input {"grid": [[1, 3], [2, 2]]}; Output [2, 4]. Input {"grid": [[9, 1, 7], [8, 9, 2], [3, 4, 6]]}; Output [9, 5]
Constraints
2 <= n == grid.length == grid[i].length <= 50 1 <= grid[i][j] <= n n For all x that 1 <= x <= n n there is exactly one x that is not equal to any of the grid members. For all x that 1 <= x <= n n there is exactly one x that is equal to exactly two of the grid members. For all x that 1 <= x <= n n except two of them there is exactly one pair of i, j that 0 <= i, j <= n - 1 and grid[i][j] == x.
Practice Find Missing and Repeated Values free on ExecCode. Browse DSA problems, topic map, and placement guides.