-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay46.cpp
More file actions
32 lines (25 loc) · 752 Bytes
/
Day46.cpp
File metadata and controls
32 lines (25 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Solution {
public:
vector<vector<int>> findWinners(vector<vector<int>>& matches) {
unordered_map<int,int> mp;
for(int i=0;i<matches.size();i++){
int loss=matches[i][1];
mp[loss]++;
}
vector<int>ans1;
vector<int>ans2;
for(int i=0;i<matches.size();i++){
int win=matches[i][0];
int loss=matches[i][1];
if(mp.find(win)==mp.end()) {
ans1.push_back(win);
mp[win]=2;
}
if(mp[loss]==1)
ans2.push_back(loss);
}
sort(ans1.begin(),ans1.end());
sort(ans2.begin(),ans2.end());
return {ans1,ans2};
}
};