For each window position, scan all k elements to find the maximum.
There are windows. Scanning each takes . Total: .
For and , that's operations. Too slow.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
For each window position, scan all k elements to find the maximum.
There are windows. Scanning each takes . Total: .
For and , that's operations. Too slow.