MCPcopy
hub / github.com/qiyuangong/leetcode / depth

Method depth

java/543_Diameter_of_Binary_Tree.java:9–15  ·  view source on GitHub ↗
(TreeNode node)

Source from the content-addressed store, hash-verified

7 return ans - 1;
8 }
9 public int depth(TreeNode node) {
10 if (node == null) return 0;
11 int L = depth(node.left);
12 int R = depth(node.right);
13 ans = Math.max(ans, L+R+1);
14 return Math.max(L, R) + 1;
15 }
16}

Callers 1

diameterOfBinaryTreeMethod · 0.95

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected