剑指offer(牛客网)二叉树的深度

it2025-03-04  27

public class Solution { public int TreeDepth(TreeNode root) { if(root == null) { return 0; } return Math.max(TreeDepth(root.left), TreeDepth(root.right)) + 1; } }

 

最新回复(0)