class Solution {
public:
int findCenter(vector<vector<int>>& edges) {
unordered_map<int, int> degree;
int max_degree = 0;
int vertex = 0;
for (auto edge : edges) {
degree[edge[0]]++;
degree[edge[1]]++;
if (degree[edge[0]] >= max_degree) {
vertex = edge[0];
max_degree = degree[edge[0]];
}
if (degree[edge[1]] >= max_degree) {
vertex = edge[1];
max_degree = degree[edge[1]];
}
}
return vertex;
}
};