Fairly, straight-forward problem. To find the center of the graph in this case where the center is a neighbor with every node other than itself - is the same as finding the node with the most neighbors.
Code
Go
Big O Analysis
-
Runtime
The runtime complexity here is where N is the number of vertices/nodes in the graph.
-
Memory
The memory usage is since we use a map to store adjacency list.
— A