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.
they give you a and b. I chose to ignore the 1-based, 0-based issues and that was ok. for instance result_array[2] is just 2, not 2-1 or 2+1 to compensate for going back and forth between 0-based and 1-based. It passed all the tests, even though I hated doing it that way. The only other thing is, they give you a start index and an end index (a and b) and you need to consider: ADD at the start index and SUBTRACT just after the end index. so result_array[b+1] -= k. -- 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 →
they give you a and b. I chose to ignore the 1-based, 0-based issues and that was ok. for instance result_array[2] is just 2, not 2-1 or 2+1 to compensate for going back and forth between 0-based and 1-based. It passed all the tests, even though I hated doing it that way. The only other thing is, they give you a start index and an end index (a and b) and you need to consider: ADD at the start index and SUBTRACT just after the end index. so result_array[b+1] -= k. -- hope that helps.