Day 21 - Merge, Detect, and Contribute
Revisiting Merge Intervals, Floyd’s Algorithm, and Kafka Open Source
Day 21 - Merge, Detect, and Contribute
Started off the day by re-solving 56. Merge Intervals again.
Now I know it inside out. Felt good to reinforce it.
Leetcode Practice
88. Merge Sorted Array
- Brute force: Just iterate both arrays and merge into a new array, then copy back
- Not optimal due to extra space
- Optimal: Start from the end, compare last indices, and fill from the back of the original array
- This avoids using extra space
287. Find the Duplicate Number
Brute force: Use a
set
orcount
array to track frequencies
As soon as frequency goes above 1 → return the element
Optimal: Floyd’s Tortoise and Hare (Cycle Detection)
- Use
slow
andfast
pointers
- Slow moves 1 step, Fast moves 2
- They’ll collide at some point inside the loop
- Then reset one to start and move both by 1 step → collision point is the duplicate
- All done in constant space
- Use
Kafka Contribution Work
Started diving into contributing to Apache Kafka’s open source.
Found a couple of issues that looked simple…
but definitely weren’t as simple as I initially thought 😅
Spent the entire rest of the day on this.
But something new, I guess. It’s fascinating to see the community support.
All in all - good problem solving + open source learning.
Let’s keep going.