Count triples (a, b, c) where a is the LCA of b and c, b and c are at the same depth, and the path to b uses only left edges while the path to c uses only right edges.
node
1
0
2
1
3
2
4
3
5
4
6
5
7
6
tree=[1, 2, 3, 4, 5, 6, 7]
Step 1 / 3
Step 1:
Compute consecutive left and right chains from each node.
Pointers: node=0
Focus: select @ [0]