In the second round of my virtual onsite, I worked on finding the fewest buses needed to travel between two stops. Routes could connect through shared stops. I modeled routes as graph nodes and used breadth-first search to count buses.
The follow-ups covered reconstructing the journey, explaining why the search found the minimum, unreachable destinations, and identical start and end stops. For reconstruction, I kept track of the previous route and transfer stop. My main takeaways were to explain the model before coding, define the variables used in complexity analysis, and raise edge cases proactively.
Discussion
Loading comments…