Skip to content

Commit c84da80

Browse files
authored
Create 1109-corporate-flight-bookings.js
1 parent 1168525 commit c84da80

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

1109-corporate-flight-bookings.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {number[][]} bookings
3+
* @param {number} n
4+
* @return {number[]}
5+
*/
6+
const corpFlightBookings = function(bookings, n) {
7+
let res = new Array(n).fill(0)
8+
for (let v of bookings) {
9+
res[v[0] - 1] += v[2]
10+
if (v[1] < n) res[v[1]] -= v[2]
11+
}
12+
for (let i = 1; i < n; ++i) res[i] += res[i - 1]
13+
return res
14+
}

0 commit comments

Comments
 (0)