Since it’s a binary search tree, we iterate based on choosing different roots.
Code below. AC on the first try, though it took me a while to figure it out.
| |
Since it’s a binary search tree, we iterate based on choosing different roots.
Code below. AC on the first try, though it took me a while to figure it out.
| |