MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / solve

Function solve

CPP/Trees/Max_Depth_BinaryTree.cpp:5–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using namespace std;
4
5int solve(TreeNode* l, TreeNode* r, int depth)
6{
7 if(l == NULL && r == NULL)
8 return depth - 1;
9
10 if(l == NULL)
11 return solve(r->left, r->right, depth+1);
12 else if(r == NULL)
13 return solve(l->left, l->right, depth+1);
14 else
15 {
16 return max(solve(l->left, l->right, depth+1), solve(r->left, r->right, depth+1));
17 }
18
19}
20
21int maxDepth(TreeNode* root) {
22 if(root == NULL)

Callers 1

maxDepthFunction · 0.70

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected