Skip to content

Commit 888fc68

Browse files
authored
Update 983-minimum-cost-for-tickets.js
1 parent 5aeb5ef commit 888fc68

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

983-minimum-cost-for-tickets.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ const mincostTickets = function(days, costs) {
77
const last7 = [], last30 = []
88
let res = 0
99
for(let d of days) {
10-
while(last7.length && last7[0][0] + 7 <= d) last7.pop()
11-
while(last30.length && last30[0][0] + 30 <= d) last30.pop()
12-
last7.push([d, res + costs[1]])
10+
while(last7.length && last7[0][0] + 7 <= d) last7.shift()
11+
while(last30.length && last30[0][0] + 30 <= d) last30.shift()
12+
last7.push([d, res + costs[1]])
1313
last30.push([d, res + costs[2]])
1414
res = Math.min(res + costs[0], last7[0][1], last30[0][1])
1515
}

0 commit comments

Comments
 (0)