Beats 97% 🚀 | Clear Explanation 📝 | Efficient Solution 💡
Found this helpful? Please upvote \uD83D\uDE4C\nYour support is appreciated!\n\n# Approach\n Describe your approach to solving the problem. \n1. Calculate total
>Found this helpful? Please upvote \uD83D\uDE4C\nYour support is appreciated!\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. __Calculate totalDistance__ by summing all distances and __clockwise distance__ by summing distances between min and max.\n2. Compute __counterclockwise distance__ as totalDistance - clockwise.\n3. __Return the minimum__ of clockwise and counterclockwise distances.\n\n\n\n\n\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {number[]} distance\n * @param {number} start\n * @param {number} destination\n * @return {number}\n */\nvar distanceBetweenBusStops = function (distance, start, destination) {\n    let n = distance.length;\n    let min = Math.min(start, destination);\n    let max = Math.max(start, destination);\n    let clockwise = 0;\n    let totalDistance = 0;\n\n    for (let i = 0; i < n; i++) {\n        totalDistance += distance[i];\n\n        if (i >= min && i < max) {\n            clockwise += distance[i];\n        }\n    }\n\n    let counterclockwise = totalDistance - clockwise;\n    return Math.min(clockwise, counterclockwise);\n};\n\n```
['JavaScript']