MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / depth

Method depth

543. Diameter of Binary Tree/Solution.cpp:27–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 Solution():cnt(0) {}
26
27 int depth(TreeNode * root) {
28 if (root == NULL) return 0;
29 int l = depth(root->left), r = depth(root->right);
30 if (l + r > cnt) cnt = l + r;
31 return max(l, r) + 1;
32 }
33
34 int diameterOfBinaryTree(TreeNode* root) {
35 depth(root);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected