第46天。
今天出游,挑到水题Maximum Depth of Binary Tree:
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
说是水题,就不讲怎么做了,直接上代码吧:
恩,突然发现好像没必要写的那么长:
恩,送上一个dicuss
中BFS的解法: