This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Query #2 | |
a = 2 | |
b = 5 | |
k = 10 | |
Array | |
10 10 -10 0 0 | |
Query #3 | |
a = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For example, to find the 3rd element in in arr_2[ ] i.e. i = 2 | |
actual_value(arr_2[2]) = actual_value(arr_2[0]) + actual_value(arr_2[1]) | |
arr_2[0] = 10 //already given | |
actual_value(arr_2[1]) = arr_2[0] + arr_2[1] | |
// 10 + 0 = 10 | |
actual_value(arr_2[2]) = arr_2[1] + arr_2[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = 5 | |
m = 3 //queries | |
Query #1 | |
a = 1 | |
b = 2 | |
k = 10 | |
Array after adding k = 10 from index a to b (1 to 2) | |
arr_1 = 10 10 0 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sample Input | |
5 3 | |
1 2 10 | |
2 5 10 | |
3 4 10 | |
Sample Output | |
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Problem : https://www.hackerrank.com/challenges/crush/problem | |
*/ | |
static long arrayManipulation(int n, int[][] queries) { | |
long[] arr = new long[n]; | |
long max = -1; | |
int a,b,k; | |
for(int i = 0; i < queries.length; i++) { | |
a = queries[i][0]; |