leetcode/src/s0104_maximum_depth_of_bina...

7 lines
187 B
C++
Raw Normal View History

2023-01-30 12:55:48 +00:00
#include "s0104_maximum_depth_of_binary_tree.hpp"
int S0104::maxDepth(TreeNode* root) {
if (root == nullptr) return 0;
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
}