很简单,也没啥坑点
class Solution { public: int maxDepth(TreeNode* root) { if(!root) return 0; int dep = max(maxDepth(root -> left), maxDepth(root -> right)) + 1; return dep; } };
2023-11-30 18:34:22
很简单,也没啥坑点
class Solution { public: int maxDepth(TreeNode* root) { if(!root) return 0; int dep = max(maxDepth(root -> left), maxDepth(root -> right)) + 1; return dep; } };