We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1f538f commit 84cb638Copy full SHA for 84cb638
2924. Find Champion II
@@ -0,0 +1,18 @@
1
+class Solution {
2
+public:
3
+ int findChampion(int n, vector<vector<int>>& edges) {
4
+ vector<int>in(n, 0);
5
+ int sz = edges.size();
6
+ for (int i = 0; i < sz; i++) {
7
+ in[edges[i][1]]++;
8
+ }
9
+ int result = -1;
10
+ for (int i = 0; i < n; i++) {
11
+ if (in[i] == 0) {
12
+ if (result >= 0) return -1;
13
+ result = i;
14
15
16
+ return result;
17
18
+};
0 commit comments