• + 3 comments

    so that when the sliciing happens on list squares[i:i+m] , it does not go above the index limit. as you can see i am doing i+m , while i is going from 0, to len() In such case, you need to reduce the window. This is known as Sliding window algorithm.