Skip to content

Commit

Permalink
Merge pull request #3399 from Ankush109/master
Browse files Browse the repository at this point in the history
Create centerofgraph.cpp
  • Loading branch information
ZoranPandovski authored Oct 19, 2022
2 parents 67d7ba3 + 7888680 commit ea0fede
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions data_structures/Graphs/centerofgraph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//1791. Find Center of Star Graph

// O(1) time complexity

class Solution {
public:
int findCenter(vector<vector<int>>& edges) {
if(edges[0][0]==edges[1][0] || edges[0][0]==edges[1][1])
{
return edges[0][0];
}
else {
return edges[0][1];
}

}
};

0 comments on commit ea0fede

Please sign in to comment.