Java | Simple | Explained
Idea: Required distance is the minimum of 2 routes which are circular complementary in nature. E.g. \n\nfor Stops B (source) and C (destination):\nroute1 = B ->
**Idea:** Required distance is the minimum of 2 routes which are circular complementary in nature. E.g. \n```\nfor Stops B (source) and C (destination):\nroute1 = B -> C\nroute2 = B -> D -> C\n```\n![image](https://assets.leetcode.com/users/images/e6ee367f-22a6-4351-ae0e-52d4109f19d1_1642423872.9258714.png)\n\n>**T/S:** O(n)/O(1), where n = size(distance)\n```\npublic int distanceBetweenBusStops(int[] distance, int start, int destination) {\n\tif (start > destination)\n\t\treturn distanceBetweenBusStops(distance, destination, start);\n\tvar route1 = 0;\n\tvar route2 = 0;\n\t\n\tfor (var stop = 0; stop < distance.length; stop++)\n\t\tif (stop >= start && stop < destination)\n\t\t\troute1 += distance[stop];\n\t\telse\n\t\t\troute2 += distance[stop];\n\t\t\t\n\treturn Math.min(route1, route2);\n}\n```\n***Please upvote if this helps***
['Java']