I never realised that during BFS in the queue approach in the following variations -
- When I mark visited only when popping from the queue
- When I mark visited when I add neighbours to the queue
Both of these methods have a strong different in time complexities. Holy molly.
The first one's time complexity goes to $$$Fibonacci(n)$$$ and the second one is our plan old linear one. I realised this today, am I an idiot or what for never questioning this.
Thanks to random solving of LC200 for this!!




