Algorithm · Amazon · Hard
A warehouse records the order in which n shipments are processed as an array shipmentOrder. This array is a permutation: each integer from 1 to n shows up once and only once. You are also given an integer windowSize. Apply the following step a single time, no more and no fewer: Pick a block of windowSize consecutive positions in the array. Rearrange only the values inside that block into ascending order. Every position outside the block keeps its value. Produce the…