MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / isBalanced

Function isBalanced

javascript/0110-balanced-binary-tree.js:7–14  ·  view source on GitHub ↗
(root)

Source from the content-addressed store, hash-verified

5 * @return {boolean}
6 */
7var isBalanced = function (root) {
8 const isBaseCase = root === null;
9 if (isBaseCase) return true;
10 if (!isAcceptableHeight(root)) return false;
11 if (!isChildBalanced(root)) return false;
12
13 return true;
14};
15
16const isChildBalanced = (root) => {
17 const left = isBalanced(root.left);

Callers 1

isChildBalancedFunction · 0.70

Calls 3

isAcceptableHeightFunction · 0.85
isChildBalancedFunction · 0.85
isRootBalancedFunction · 0.85

Tested by

no test coverage detected