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

Method checkAncestors

javascript/1993-operations-on-tree.js:92–99  ·  view source on GitHub ↗

* Helper method to check ancestors * Time O(n) | Space O(1) * @param {number} index * @return {boolean}

(index)

Source from the content-addressed store, hash-verified

90 * @return {boolean}
91 */
92 checkAncestors(index) {
93 let node = this.parent[index];
94 while (node !== -1) {
95 if (this.treeHash[node]) return false;
96 node = this.parent[node];
97 }
98 return true;
99 }
100
101 /**
102 * Helper method to check descendants

Callers 1

upgradeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected