Skip to content

Instantly share code, notes, and snippets.

@ytnk531
Last active August 18, 2018 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytnk531/007e8aca909a758207c67f7e86911acd to your computer and use it in GitHub Desktop.
Save ytnk531/007e8aca909a758207c67f7e86911acd to your computer and use it in GitHub Desktop.
import java.util.Arrays;
public class ArrayManupilation {
static long arrayManipulation(int n, int[][] queries) {
long[] arr = new long[n+1];
for (int[] query : queries) {
for(int i = query[0];i <= query[1]; i++) {
arr[i] += query[2];
}
}
return Arrays.stream(arr).max().getAsLong();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment