LeetCode --- 1184. Distance Between Bus Stops 解题报告
Posted 杨鑫newlfe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1184. Distance Between Bus Stops 解题报告相关的知识,希望对你有一定的参考价值。
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
.
The bus goes along both directions i.e. clockwise and counterclockwise.
Return the shortest distance between the given start
and destination
stops.
Example 1:
Input: distance = [1,2,3,4], start = 0, destination = 1 Output: 1 Explanation: Distance between 0 and 1 is 1 or 9, minimum is 1.
Example 2:
以上是关于LeetCode --- 1184. Distance Between Bus Stops 解题报告的主要内容,如果未能解决你的问题,请参考以下文章
LeetCode 1184 公交站间的距离[数组] HERODING的LeetCode之路