|
1 | 1 | packagecom.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1184. Distance Between Bus Stops |
5 |
| - * |
6 |
| - * A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n. |
7 |
| - * The bus goes along both directions i.e. clockwise and counterclockwise. |
8 |
| - * Return the shortest distance between the given start and destination stops. |
9 |
| - * |
10 |
| - * Example 1: |
11 |
| - * Input: distance = [1,2,3,4], start = 0, destination = 1 |
12 |
| - * Output: 1 |
13 |
| - * Explanation: Distance between 0 and 1 is 1 or 9, minimum is 1. |
14 |
| - * |
15 |
| - * Example 2: |
16 |
| - * Input: distance = [1,2,3,4], start = 0, destination = 2 |
17 |
| - * Output: 3 |
18 |
| - * Explanation: Distance between 0 and 2 is 3 or 7, minimum is 3. |
19 |
| - * |
20 |
| - * Example 3: |
21 |
| - * Input: distance = [1,2,3,4], start = 0, destination = 3 |
22 |
| - * Output: 4 |
23 |
| - * Explanation: Distance between 0 and 3 is 6 or 4, minimum is 4. |
24 |
| - * |
25 |
| - * Constraints: |
26 |
| - * 1 <= n <= 10^4 |
27 |
| - * distance.length == n |
28 |
| - * 0 <= start, destination < n |
29 |
| - * 0 <= distance[i] <= 10^4 |
30 |
| - * */ |
31 | 3 | publicclass_1184 {
|
32 | 4 | publicstaticclassSolution1 {
|
33 | 5 | publicintdistanceBetweenBusStops(int[]distance,intstart,intdestination) {
|
|