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)


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