MCPcopy Create free account
hub / github.com/Blankj/awesome-java-leetcode / Solution

Class Solution

src/com/blankj/easy/_0104/Solution.java:14–26  ·  view source on GitHub ↗

author: Blankj blog : http://blankj.com time : 2017/10/09 desc :

Source from the content-addressed store, hash-verified

12 * </pre>
13 */
14public class Solution {
15 public int maxDepth(TreeNode root) {
16 if (root == null) return 0;
17 return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
18 }
19
20 public static void main(String[] args) {
21 Solution solution = new Solution();
22 System.out.println(solution.maxDepth(TreeNode.createTestData("[]")));
23 System.out.println(solution.maxDepth(TreeNode.createTestData("[1,2,2,3,4,4,3]")));
24 System.out.println(solution.maxDepth(TreeNode.createTestData("[9,-42,-42,null,76,76,null,null,13,null,13]")));
25 }
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected