Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 0b94e1d

Browse files
committed
1124 done
1 parent a2267b3 commit 0b94e1d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ func longestWPI(hours []int) int {
1212
//
1313
if count > 0 {
1414
res = i + 1
15-
} else if count < 0 {
15+
} else {
1616
if rec[1-count] > 0 {
17-
res = max(res, i-rec[1-count])
17+
res = max(res, i-rec[1-count]+1)
1818
}
19-
if rec[-count] == 0 { // just record negative count
20-
rec[-count] = i
19+
if rec[-count] == 0 {
20+
rec[-count] = i + 1
2121
}
22-
} else if hours[0] <= 8 {
23-
res = i
2422
}
2523
}
2624
return res

0 commit comments

Comments
 (0)