Here is another problem testing basic graph properties. Problem: Find Center of Star Graph A star graph has one center node connected to all others. The center appears in every edge because it is the only hub.
You do not need to count all degrees. Look at the first two edges. The node appearing in both must be the center. This observation gives you an solution instead of .
Space complexity is for the data structures used.