Subarray Division 1

  • + 3 comments

    Hi,

    Of course!

    This is called 'sliding window' approach. We need a contiguous segment of specified length, and that segment should match some requirements. We store the start of the segment and everytime time the length of the segment is equal to the required one (to calculate the length we subtract start index from the current index), we increment the start index to find another segment already starting with the next element and with the specified length.

    And, as we sum elements on the go, we need to subtract the start element value from the total sum, so to have a currect sum for the next segment.

    Let me know if it is still unclear.