Skip to content

Commit 95113f4

Browse files
authored
Create Solution.java
1 parent 0eb964f commit 95113f4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public int[] corpFlightBookings(int[][] bookings, int n) {
3+
int[] res = new int[n];
4+
for (int[] booking : bookings) {
5+
int b = booking[0] - 1, e = booking[1], k = booking[2];
6+
res[b] += k;
7+
if (e < n) {
8+
res[e] -= k;
9+
}
10+
}
11+
for (int i = 1; i < n; ++i) {
12+
res[i] += res[i - 1];
13+
}
14+
return res;
15+
}
16+
}

0 commit comments

Comments
 (0)