Maximum Depth of Binary Tree LeetCode solution in C++

1
class Solution {
2
public:
3
int maxDepth(TreeNode *root) {
4
if (root == NULL) return 0;
5
int left = maxDepth(root->left);
6
int right = maxDepth(root->right);
7
return max(left, right) + 1;
8
}
9
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0