Find the center of a star graph given its edges.
Unlock detailed company stats for this questionUpgrade
Given an undirected graph of n nodes labeled 1 to n that is a star graph (one center node, every other node connected directly to it) and an array of edges where edges[i] = [u, v], find the center node.
Example: edges = [[1,2],[2,3],[4,2]] -> 2.
O(1) solution: the center appears in every edge, so compare the first two edges.
Format · Technical round.
Community answers
No answers contributed by the community yet.
Related questions
Find the number of connected components in a graph.Find the issue in a given piece of C++ code.Reverse the edges of a directed graph.Related courses

Course

Course
Course
