mirror of
https://github.com/20kaushik02/leetcode-gulag.git
synced 2025-12-06 09:54:07 +00:00
18 lines
310 B
C++
18 lines
310 B
C++
#include "soln.hpp"
|
|
|
|
int Solution::max(int a, int b)
|
|
{
|
|
return a > b ? a : b;
|
|
}
|
|
int Solution::maxDepth(TreeNode *root)
|
|
{
|
|
if (root == nullptr)
|
|
{
|
|
return 0;
|
|
}
|
|
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
|
|
}
|
|
bool Solution::test(TreeNode *root, int answer)
|
|
{
|
|
return maxDepth(root) == answer;
|
|
} |