My first instinct was to just do a DFS and track the current run length, resetting whenever the sequence broke.
Use a post-order DFS that returns the longest strictly increasing path starting at each node, combining results from left and right children. For each node, compute the best increasing path that starts at that node by considering valid child paths where the child's value is greater, then update a global maximum with the sum of the two best child paths plus one (the node itself).
Pro tip: Clarify that the path must be strictly increasing and can go through a node by combining its left and right child paths, but only if both child values are greater than the node's value. Also, mention that the path doesn't need to be root-to-leaf, so you must track the global maximum at every node.
Confirm that the path follows parent-child edges, values must be strictly increasing, and the path length is measured in nodes. Discuss edge cases like empty tree, single node, and trees with duplicate values (though BSTs typically have unique values).
Design a DFS function that returns the length of the longest strictly increasing path starting at the current node and going downwards. This function will be called recursively on left and right children.
At each node, compute the best increasing path starting at the node by considering valid child paths (where child value > node value). Update a global maximum with the sum of the two best child paths plus one (the node itself) to account for paths that pass through the node.
For null nodes, return 0. For leaf nodes, return 1. Ensure the function returns the longest increasing path starting at the current node (1 + max of valid child paths).
State that the time complexity is O(n) since each node is visited once, and space complexity is O(h) for recursion stack. Walk through a small example to verify correctness.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.