您的位置: 首页 > 文章 > Leetcode#104. 二叉树的最大深度,C++实现 Leetcode#104. 二叉树的最大深度,C++实现 分类: 文章 • 2024-06-05 20:11:28 目录 1. 题目 2. 方法一 2.1. 代码 2.2. 结果 1. 题目 2. 方法一 2.1. 代码 class Solution { public: int maxDepth(TreeNode* root) { if(root==NULL) return 0; return max(maxDepth(root->left),maxDepth(root->right))+1; } }; 2.2. 结果