We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7ef3db5 commit df90571Copy full SHA for df90571
scripts/algorithms/F/Find Center of Star Graph/Find Center of Star Graph.cpp
@@ -1,10 +1,11 @@
1
+// Runtime: 436 ms (Top 21.75%) | Memory: 68.2 MB (Top 42.59%)
2
class Solution {
3
public:
4
int findCenter(vector<vector<int>>& edges) {
5
//the center of a graph will be connected to all the edges
6
//so keep a track of number of edges for every node
- //if number of edges is n then it is the center
7
-
+ //if number of edges is n then it is the center
8
+
9
//to store the number of edges for every node
10
int n=edges.size();
11
vector<int> mp(n+2,0);
@@ -18,6 +19,6 @@ class Solution {
18
19
return edges[i][1];
20
}
21
return 0;
22
23
-};
24
+};
0 commit comments