(root, tree)
| 10 | |
| 11 | class LCABinaryLifting extends BinaryLifting { |
| 12 | constructor(root, tree) { |
| 13 | super(root, tree) |
| 14 | this.depth = new Map() // depth[node] stores the depth of node from root |
| 15 | this.depth.set(root, 1) |
| 16 | this.dfsDepth(root, root) |
| 17 | } |
| 18 | |
| 19 | dfsDepth(node, parent) { |
| 20 | // DFS to find depth of every node in the tree |