Skip to content

Commit bca3f78

Browse files
authored
Update 1109-corporate-flight-bookings.js
1 parent 6306891 commit bca3f78

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1109-corporate-flight-bookings.js

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/**
2+
* @param {number[][]} bookings
3+
* @param {number} n
4+
* @return {number[]}
5+
*/
6+
const corpFlightBookings = function(bookings, n) {
7+
const arr = Array(n + 2).fill(0)
8+
for(const [s, e, num] of bookings) {
9+
arr[s] += num
10+
arr[e + 1] -= num
11+
}
12+
for(let i = 1; i < n + 2; i++) {
13+
arr[i] += arr[i - 1]
14+
}
15+
arr.pop()
16+
arr.shift()
17+
return arr
18+
};
19+
20+
// another
21+
122
/**
223
* @param {number[][]} bookings
324
* @param {number} n

0 commit comments

Comments
 (0)