Java O(n)
\n    public int distanceBetweenBusStops(int[] ds, int s, int e) {\n        if (s > e) return distanceBetweenBusStops(ds, e, s);\n        if (s == e) return 0;\
```\n    public int distanceBetweenBusStops(int[] ds, int s, int e) {\n        if (s > e) return distanceBetweenBusStops(ds, e, s);\n        if (s == e) return 0;\n        int res = 0, n = ds.length, sum = 0;\n        for (int i = 0; i < n; i++) {\n            sum += ds[i];\n            if (i >= s && i < e) res += ds[i];\n        }\n        return Math.min(res, sum - res);\n    }\n```
[]