leetcode

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

2924.cpp (336B)


      1 class Solution {
      2   public:
      3     int findChampion(int n, const vector<vector<int>> &edges) const {
      4         bitset<128> bs;
      5         for (const auto &edge : edges)
      6             bs.set(edge[1]);
      7         if (bs.count() + 1 != n) return -1;
      8         for (int i = 0; i < n; i++)
      9             if (!bs.test(i)) return i;
     10         return -2;
     11     }
     12 };