LeetCode solutions

1287. Distance Between Bus Stops

My accepted Python solution to LeetCode problem 1287, Distance Between Bus Stops, running in 39ms.

  • Difficulty: Easy
  • Python
  • Runtime 39ms
  • Memory 18.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 39ms, memory 18.3MB, accepted 2025-12-30.

python
class Solution:
    def distanceBetweenBusStops(self, distance: List[int], start: int, destination: int) -> int:
        if start > destination:
            start, destination = destination, start
        
        clockwise = sum(distance[start:destination])
        total = sum(distance)
        counterclockwise = total - clockwise
        
        return min(clockwise, counterclockwise)

Source