当前位置:网站首页>【每日一题】1184. 公交站间的距离
【每日一题】1184. 公交站间的距离
2022-07-25 06:43:00 【爱写Bug的王六六】
环形公交路线上有 n 个站,按次序从 0 到 n - 1 进行编号。我们已知每一对相邻公交站之间的距离,distance[i] 表示编号为 i 的车站和编号为 (i + 1) % n 的车站之间的距离。
环线上的公交车都可以按顺时针和逆时针的方向行驶。
返回乘客从出发点 start 到目的地 destination 之间的最短距离。

输入:distance = [1,2,3,4], start = 0, destination = 1
输出:1
解释:公交站 0 和 1 之间的距离是 1 或 9,最小值是 1。
简单模拟题:
用 i 和 j 分别代表往前和往后走的指针,a 和 b 分别统计两种走法的总成本。
class Solution {
public int distanceBetweenBusStops(边栏推荐
- 杜教筛
- 【transformer】DeiT
- CRC8 CRC16 table lookup method
- [datawhale202207] reinforcement learning: strategy gradient and near end strategy optimization
- Clear wechat applet and wechat H5 cache
- js数据类型的判断——案例6精致而优雅的判断数据类型
- JS gets the text selected by the mouse and is in the selected state
- Introduction to the usage of explain and the meaning of result field in MySQL
- Basic usage of thread class
- Health clock in daily reminder tired? Then let automation help you -- hiflow, application connection automation assistant
猜你喜欢

Mlx90640 infrared thermal imager temperature measurement module development notes (I)

Use abp Zero builds a third-party login module (III): web side development

【transformer】DeiT

What determines the "personality" of AI robots?

10分钟看懂Jmeter 是如何玩转 redis 数据库的

如何学习 C 语言?

微生物健康,不要排斥人体内微生物

Addition, deletion, modification and query of DOM elements

Basic usage of thread class

MySQL remote login
随机推荐
C#控件开源库:MetroFramework的下载
常吃发酵馒头是否会伤害身体
Bubble sort code implementation
Easy gene chip SEQ analysis method: practical workflow and advanced applications
MySQL remote login
Robot engineering - teaching quality - how to judge
C # read Beckhoff variable
长安链Solidity智能合约调用原理分析
Koa2 learning
JS array = number assignment changes by one, causing the problem of changing the original array
[jailhouse article] base architectures for virtual physical computing (2018)
Do you know the same period last year in powerbi
The ultimate difference between MVC and three-tier architecture
[reprint] pycharm packages.Py program as executable exe
流量对于元宇宙来讲并不是最重要的,能否真正给传统的生活方式和生产方式带来改变,才是最重要的
机器人工程-教学品质-如何判定
C#--MetroFramework框架调用metroModernUI库,并在工具栏使用
Keilc51 usage details (III)
JSON、
Introduction to the usage of explain and the meaning of result field in MySQL