Bus Routes, is a LeetCode problem. In this post we will see how we can solve this challenge in Python

Problem Description

Example: Input: routes = [[1, 2, 7], [3, 6, 7]] S = 1 T = 6 Output: 2 Explanation: The best strategy is take the first bus to the bus stop 7, then take the second bus to the bus stop 6.

Note:

1 <= routes.length <= 500 .

1 <= routes[i].length <= 500 .

0 <= routes[i][j] < 10 ^ 6 .

1 <= routes.length <= 500.

1 <= routes[i].length <= 5 ....

You can find the full details of the problem Bus Routes at LeetCode

Solution: Please check the main.py snippet for the solution.

This solution originally posted at: Github by @kamyu104