Commit 758338a
committed
Add MaxDepth method to calculate binary tree depth
This commit introduces a new method `MaxDepth` in the `Solution` class under the `LeetCodeNote` namespace. The method computes the maximum depth of a binary tree using recursion, handling null input by returning 0. It evaluates the depths of the left and right subtrees and returns the greater value plus one.1 parent 3096907 commit 758338a
1 file changed
+15
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments