Gas Station
来源:互联网 发布:淘宝男装销量店铺排行 编辑:程序博客网 时间:2024/06/07 04:45
class Solution {public: int canCompleteCircuit(vector<int> &gas, vector<int> &cost) { const size_t size=gas.size();int curGas=0,total=0,record=0;for(size_t i=0;i<size;i++){curGas=curGas+gas[i]-cost[i];total=total+gas[i]-cost[i];if(curGas < 0){curGas=0;record=i+1;}} return total>=0?record:-1; }};
0 0
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- Gas Station
- 利用MyBatis Generator自动生成DO&DAO&mapper
- SimpleDateFormat使用详解
- 在VS中设置预编译头从而提高编译速度
- NYOJ236 心急的C小加&NYOJ 16 矩形嵌套
- 位与或非
- Gas Station
- 改版造成网站降权 怎样应对让其快速恢复
- UISegmentedControl使用技巧
- Android 如何实现分享图片功能
- 几个重要库函数的实现-strcpy,strncpy,memcpy,memset
- obj-m ,obj-y,obj-n
- 伸展树的读书笔记
- 时间复杂度和空间复杂度小结
- C#-二维数组---ShinePans