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.
Yes, this works for me.
I'm not subtracting for all the iteration. Substraction is done only when the required number of consecutive element are processed. This substraction allows me not recalculate the sum everytime, as it already hold the summed value of consecutive element. To calculate the next set of summation, I just need to subtract the 1st added element.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Subarray Division
You are viewing a single comment's thread. Return to all comments →
Yes, this works for me. I'm not subtracting for all the iteration. Substraction is done only when the required number of consecutive element are processed. This substraction allows me not recalculate the sum everytime, as it already hold the summed value of consecutive element. To calculate the next set of summation, I just need to subtract the 1st added element.