Find a Valid Binary Tree Root in a Degree-Bounded Tree

Given an acyclic, undirected, connected graph (a tree) in which every vertex has at most 3 neighbours, represented by an adjacency list graph where graph[i] lists the neighbours of vertex i. Decid...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: