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.
One insight that might help is that we're keeping track of the change in values rather than the values themselves at each index. Therefore, by adding the k at a and subtracting it after b, we are saying that at a the total value increases by k compared to the previous element, and after b the total value decreases by k compared to b. Hope that helps!
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 →
One insight that might help is that we're keeping track of the change in values rather than the values themselves at each index. Therefore, by adding the k at a and subtracting it after b, we are saying that at a the total value increases by k compared to the previous element, and after b the total value decreases by k compared to b. Hope that helps!