When I looked at this problem, I thought the best way is to use each node as a root and do dfs and record the depth. The root with the min depth is the answer. However, it does time out when run. Does anyone know if it is a good approach for this problem?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.