This theory is part of Premium
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricingFind the longest stretch that alternates left, right, left, right.
What this asks
Find the longest stretch that alternates left, right, left, right.
Return two lengths per node, the best run ending in a left step and in a right step, and update the running best at every node.
The full write-up (worked counting examples, the trap list and the interview playbook) unlocks with a Premium plan, along with every Pro visualizer.
See pricing