I dont understand why the first for loop is needed. Is it used for computation of maximum element during 1st run of sliding window while the subsequent runs of sliding window will use the condition in second for loop?
Why do we need the first for loop if it is already included in the second for loop
First loop is to gather the maximum element among first k elements. After that we will remove one from left and add one to right and then get the maximum.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.