Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit381c4e1

Browse files
authored
Update 0134.加油站.md
添加 0134.加油站.md Golang 版本
1 parent7221797 commit381c4e1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎problems/0134.加油站.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@ class Solution:
240240
```
241241

242242
Go:
243+
```go
244+
funccanCompleteCircuit(gas []int,cost []int)int {
245+
curSum:=0
246+
totalSum:=0
247+
start:=0
248+
fori:=0; i <len(gas); i++ {
249+
curSum += gas[i] - cost[i]
250+
totalSum += gas[i] - cost[i]
251+
if curSum <0 {
252+
start = i+1
253+
curSum =0
254+
}
255+
}
256+
if totalSum <0 {
257+
return -1
258+
}
259+
return start
260+
}
261+
```
243262

244263
#"diff-7303e5c71a8207887099cf22a685e7950bcc58f48f9b7ffc6fbf8933fc3e663f-245-264-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">245
264
```Javascript

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp