节点数据结构 class TreeNode { TreeNode left = null; TreeNode right = null; } 最大深度,基本思路是:使用递归,分别求出左子树的深度.右子树的深度,两个深度的较大值+1就是最大深度. // 获取最大深度 public static int getMaxDepth(TreeNode treeNode) { if (treeNode == null) return 0; else { int left = getMaxDepth(tree
Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null. The width of one level