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 index range is inclusive of the start and end indices: [0, 1, 2].
we are looking at the set of chocolates from i to i+m and determining if that set meets our criteria. if it does, we increment total. then we increment i and look at the next set, and so on until we have traversed the array.
i like victorz's analogy below: it is a "sliding window."
i 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
Subarray Division
You are viewing a single comment's thread. Return to all comments →
the index range is inclusive of the start and end indices: [0, 1, 2].
we are looking at the set of chocolates from i to i+m and determining if that set meets our criteria. if it does, we increment total. then we increment i and look at the next set, and so on until we have traversed the array.
i like victorz's analogy below: it is a "sliding window."
i hope that helps.