Alright, so day 1 of the 90-day roadmap is done [Roadmap link in the footer]
The goal today was volume and rhythm.
I wanted to start with a topic I felt confident in which is Binary Trees (to build some momentum before the week gets chaotic)
I managed to clear five problems today.
The Warm Up:
I started with standard traversal problems to get my brain used to recursion again.
Initially, just DFS.
Then,
1. Right Side View & 2. Bottom Left Value [LC-Medium]
Standard DFS approaches. These felt like muscle memory. (Maintain a level and a list to have all the values)
3. Uni-valued Binary Tree [LC-Easy]
A simple traversal check of values.
4. Count Good Nodes in Binary Tree [LC-Medium]
This was also a smooth one, surprisingly.
The logic is straightforward: Carry the maximum value encountered so far down into the recursive calls. If the current node is greater than or equal to that max, it’s a good node.
Lasly, The “Hard” Problem: Binary Tree Maximum Path Sum
It’s tagged “Hard,”
but honestly, it just requires knowing one specific constraint about recursion. And no, I could not solve this in one go, but I was super close.
I had to briefly check the solution eventually, just to confirm my suspicion about how paths are split, but the logic is actually simple.
The Catch:
A node acts differently depending on who is asking:
- For the Global Answer: It can form a “V” (Left + Root + Right) to potentially be the max path.
- For its Parent: It can only offer one path (Root + Max(Left, Right)).
Once you accept you can’t pass the “V” shape up, the code writes itself.
It’s a standard traversal with a global variable update.
The Physical Log
Day 1 wasn’t just about code; it’s about not dying while coding.
- Activity: 30-minute outdoor walk.
- Strength: 1 set of lunges.