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.
The magic thing about this is that it's all about prefix-sum...
Seriously, when i understood the logic i tought how funny and simple is that solution... That's why algorithms is so amazing to me.
PS: To avoid the if in the q + 1 <= N just add 2 to the size of the array instead of 1.
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 →
The magic thing about this is that it's all about prefix-sum... Seriously, when i understood the logic i tought how funny and simple is that solution... That's why algorithms is so amazing to me.
PS: To avoid the if in the q + 1 <= N just add 2 to the size of the array instead of 1.