educative.io

Remarks on the Python solution

I would give some remarks on the Python solution as following:

The 3 lines of code: (line 28 to line 30)

temp = window.popleft()
result.append(arr[temp])
window.appendleft(temp)

can be replace by one line which should be the same as the line 15? The idea is to pick the front of the deque which is the max, so:

result.append(arr[window[0]])

is fine right?

And

In the sixth step/figure (of seven steps), should the last line be Max is now array[3] = 1?
See here

Thanks.

Hi Son_Chu,
That’s a great idea! Thanks for pointing out the issue in the slide. The code and slides have been updated. Feel free to have a look.