We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This question feels disingenuous.
For people who have trouble understanding it, here's a simplified explanation.
You get 2 variables as input. N (an int) and Queries (a 2D array of ints).
N is the size of your base array, you create that.
Queries is a list of operations to perform on the array.
There's 3 numbers in queries. The first is the starting point, the second is the ending point, and the third is the number you add.
The idea is you take your base array, then add the third number to the entries in that array between the index of N[Queries[0]] and N[Queries[1]].
What feels disingenuous is you can't actually do that. Writing the algorithm in the way they explain will give you the correct results, but between tests 7 and 13 you'll end up failing to execute fast enough.
There's a different method you'll have to use (you can google it). This question wouldn't be half as difficult if they didn't mislead you in the explanation.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
This question feels disingenuous.
For people who have trouble understanding it, here's a simplified explanation.
You get 2 variables as input. N (an int) and Queries (a 2D array of ints).
N is the size of your base array, you create that.
Queries is a list of operations to perform on the array.
There's 3 numbers in queries. The first is the starting point, the second is the ending point, and the third is the number you add.
The idea is you take your base array, then add the third number to the entries in that array between the index of N[Queries[0]] and N[Queries[1]].
What feels disingenuous is you can't actually do that. Writing the algorithm in the way they explain will give you the correct results, but between tests 7 and 13 you'll end up failing to execute fast enough.
There's a different method you'll have to use (you can google it). This question wouldn't be half as difficult if they didn't mislead you in the explanation.