package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/corporate-flight-bookings/
 */
public class Problem1109 {
    public int[] corpFlightBookings(int[][] bookings, int n) {
        int[] answer = new int[n];
        for (int[] booking : bookings) {
            for (int i = booking[0]; i <= booking[1]; i++) {
                answer[i - 1] += booking[2];
            }
        }
        return answer;
    }

    public static void main(String[] args) {
        Problem1109 prob = new Problem1109();
        System.out.println(Arrays.toString(prob.corpFlightBookings(new int[][]{
            {1, 2, 10}, {2, 3, 20}, {2, 5, 25}
        }, 5))); // [10,55,45,25,25]
    }
}

@@ -16,34 +16,8 @@
 e;%0A%0A
-import java.util.Arrays;%0A%0A
 /**%0A
@@ -262,19 +262,32 @@
     
-for (int i 
+answer%5Bbooking%5B0%5D - 1%5D +
 = bo
@@ -296,17 +296,28 @@
 ing%5B
-0%5D; i %3C= 
+2%5D;%0A            if (
 book
@@ -326,13 +326,12 @@
 g%5B1%5D
-; i++
+ %3C n
 ) %7B%0A
@@ -357,16 +357,21 @@
 wer%5B
-i - 1%5D +
+booking%5B1%5D%5D -
 = bo
@@ -416,284 +416,110 @@
     
-return answer;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem1109 prob = new Problem1109();%0A        System.out.println(Arrays.toString(prob.corpFlightBookings(new int%5B%5D%5B%5D%7B%0A            %7B1, 2, 10%7D, %7B2, 3, 20%7D, %7B2, 5, 25%7D%0A        %7D, 5))); // %5B10,55,45,25,25%5D
+for (int i = 1; i %3C n; i++) %7B%0A            answer%5Bi%5D += answer%5Bi - 1%5D;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1109