Skip to content

Commit 6b97c6c

Browse files
committed
Add C++ solution of problem #2965
1 parent ebc9c7b commit 6b97c6c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

2965/solution.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
vector<int> findMissingAndRepeatedValues(vector<vector<int>>& g) {
4+
int n = g.size();
5+
vector<int> cnt(n * n + 1);
6+
for(auto v : g) {
7+
for(int e : v)
8+
cnt[e]++;
9+
}
10+
11+
vector<int> ans(2);
12+
for(int i = 1; i <= n * n; i++) {
13+
if(cnt[i] == 2)
14+
ans[0] = i;
15+
else if(cnt[i] == 0)
16+
ans[1] = i;
17+
}
18+
return ans;
19+
}
20+
};

0 commit comments

Comments
 (0)