Skip to content

Commit d797cde

Browse files
add a solution for 370
1 parent 4eb16f0 commit d797cde

File tree

1 file changed

+12
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+12
-0
lines changed

src/main/java/com/fishercoder/solutions/_370.java

+12
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,16 @@ public int[] getModifiedArray(int length, int[][] updates) {
2323
return nums;
2424
}
2525
}
26+
27+
public static class Solution2 {
28+
public int[] getModifiedArray(int length, int[][] updates) {
29+
int[] result = new int[length];
30+
for (int[] update : updates) {
31+
for (int i = update[0]; i <= update[1]; i++) {
32+
result[i] += update[2];
33+
}
34+
}
35+
return result;
36+
}
37+
}
2638
}

0 commit comments

Comments
 (0)