leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1791.cpp (400B)


      1 class Solution {
      2   public:
      3     int findCenter(vector<vector<int>> &edges) {
      4         unordered_set<int> us;
      5 
      6         for (auto &p : edges) {
      7             if (us.count(p[0]))
      8                 return p[0];
      9             else
     10                 us.insert(p[0]);
     11             if (us.count(p[1]))
     12                 return p[1];
     13             else
     14                 us.insert(p[1]);
     15         }
     16         return -1;
     17     }
     18 };