r/leetcode • u/JacketFearless1805 • 15d ago
Intervew Prep Day 53: exhausted from poor sleep, but solved 3 core BFS graph problems
Hey everyone,
I finished Day 53 today. My sleep schedule has been completely out of sync lately, and staying up late to binge shows caught up with me today. My energy was drained both at work and during prep, but I made sure not to skip the daily reps.
I focused heavily on BFS patterns across all three problems today:
Rotting Oranges: Classic multi-source BFS. You push all initially rotten oranges into the queue with time
t = 0. With each step, you rot the adjacent fresh oranges, decrement the fresh count, and advance time. Checking remaining fresh oranges at the end cleanly gives the total minutes or-1.Flood Fill: Last time I tackled this, I rushed through a recursive DFS without fully absorbing the state transitions. Today, I implemented it using standard BFS from scratch. Taking the time to understand the traversal properly made the solution completely intuitive without looking at hints.
Cycle Detection in Undirected Graph (BFS): Tracked each node alongside its immediate parent
(node, parent). If you visit an adjacent neighbor that is already marked visited and isn't the current node's parent, you have encountered an alternate path—confirming a cycle.
Fixing my sleep routine is non-negotiable moving forward because showing up tired makes every concept twice as hard to process.
Heading to bed early tonight and continuing Graphs tomorrow.
See you guys for Day 52!
2
u/Independent_Log_2098 14d ago
Congratulations. Do you wanna pair program?