Shuo Wang
Jan 16, 2021

--

Hello Ryan, thank you for the question!

In my implementation of the the find_path, the returned path starts from root, so all paths actually start with the same value.

In my example the two paths are:

(0, 2, 6, 9)

(0, 2, 6, 10)

so you see, the values for index: 0, 1, 2 are the same for the two paths. Only until we reach index 3, does the value become different (9 vs 10). and we take the immediate preceding index, 2, to get the lowest common ancestor, in this case 6.

Hope this helps!

Shuo

--

--

Shuo Wang
Shuo Wang

Written by Shuo Wang

Interesting pieces on various topics in finance and technology.

No responses yet