@@ -131,36 +131,11 @@ return Arrays.copyOfRange(tmp, 1, n+1);
131131
132132``` java
133133// java
134- // LC 370
135- class Solution {
136- public int [] getModifiedArray (int length , int [][] updates ) {
137- // nums 初始化为全 0
138- int [] nums = new int [length];
139- // 构造差分解法
140- Difference df = new Difference (nums);
141-
142- for (int [] update : updates) {
143- int i = update[0 ];
144- int j = update[1 ];
145- int val = update[2 ];
146- df. increment(i, j, val);
147- }
148-
149- return df. result();
150- }
151- }
152- ```
153-
154- ### Corporate Flight Bookings
134+ // LC 370
155135
156- ``` java
157- // java
158- // LC 1109
159136
160137// V0
161138// IDEA : DIFFERENCE ARRAY
162- // LC 1109
163- // https://github.com/yennanliu/CS_basics/blob/master/leetcode_java/src/main/java/LeetCodeJava/Array/CorporateFlightBookings.java
164139public static int [] getModifiedArray(int length, int [][] updates) {
165140
166141int [] tmp = new int [length + 1 ]; // or new int[length]; both works
@@ -191,6 +166,32 @@ for (int i = 1; i < tmp.length; i++) {
191166return Arrays . copyOfRange(tmp, 0 , length); // return the sub array between 0, lengh index
192167}
193168
169+ // V1
170+ class Solution {
171+ public int [] getModifiedArray (int length , int [][] updates ) {
172+ // nums 初始化为全 0
173+ int [] nums = new int [length];
174+ // 构造差分解法
175+ Difference df = new Difference (nums);
176+
177+ for (int [] update : updates) {
178+ int i = update[0 ];
179+ int j = update[1 ];
180+ int val = update[2 ];
181+ df. increment(i, j, val);
182+ }
183+
184+ return df. result();
185+ }
186+ }
187+ ```
188+
189+ ### Corporate Flight Bookings
190+
191+ ``` java
192+ // java
193+ // LC 1109
194+
194195// V1
195196class Solution {
196197 public int [] corpFlightBookings (int [][] bookings , int n ) {
0 commit comments