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

Function isAcceptableHeight

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

Source from the content-addressed store, hash-verified

21};
22
23const isAcceptableHeight = (root) => {
24 const left = getHeight(root.left);
25 const right = getHeight(root.right);
26
27 const difference = Math.abs(left - right);
28
29 return difference <= 1;
30};
31
32const getHeight = (root) => {
33 const isBaseCase = root === null;

Callers 1

isBalancedFunction · 0.85

Calls 1

getHeightFunction · 0.70

Tested by

no test coverage detected