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

Commit 3204c90

Browse files
committed
1109 done
1 parent b1e5224 commit 3204c90

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package problem1109
22

33
func corpFlightBookings(bookings [][]int, n int) []int {
4-
res := make([]int, n)
4+
res := make([]int, n+1)
55
for _, b := range bookings {
66
i, j, k := b[0], b[1], b[2]
7-
for m := i - 1; m < j; m++ {
8-
res[m] += k
9-
}
7+
res[i-1] += k
8+
res[j] -= k
109
}
1110

12-
return res
11+
for i := 1; i < n; i++ {
12+
res[i] += res[i-1]
13+
}
14+
15+
return res[:n]
1316
}

0 commit comments

Comments
 (0)