You are viewing a single comment's thread. Return to all comments →
why is the range subtracted from len()+1?
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.