Definition at line 5 of file main.cpp.
◆ findMissingAndRepeatedValues()
| vector< int > Solution::findMissingAndRepeatedValues |
( |
vector< vector< int > > & |
grid | ) |
|
|
inline |
Definition at line 8 of file main.cpp.
9 {
10
11 int n = (int)grid.size();
12 vector<int> values(n * n + 1, 0);
13 int a, b;
14 for (const auto& row: grid)
15 {
16 for (int el: row)
17 {
18 if (values[el] != 0)
19 a = el;
20 else
21 values[el] = 1;
22 }
23 }
24
25 for (int i = 1; i <= n * n; ++i)
26 {
27 if (i == a)
28 continue;
29 else if (values[i] == 0)
30 {
31 b = i;
32 break;
33 }
34 }
35 vector<int> answer = {a, b};
36 return answer;
37 }
Referenced by main().
The documentation for this class was generated from the following file: