Link: https://leetcode.com/problems/linked-list-in-binary-tree/
Solution:
Topics: tree, linked list, DFS
Intuition
This is a pretty easy problem but sadly I struggled with it because I was committed to solving it with a single DFS function and nothing more. This led to branch factor explosion, and a myriad of edge cases. I made it work, but it was ugly.
It then occurred to me (duh) that we can simply find all potential starting points and then simply verify if they lead to the list being exhausted. This does require two functions but it is a far more logical and simple approach to the problem.
Implementation
Visual
Review 1
Crushed this one.