← Questions

Largest permutation after sorting one fixed-length window

0
AmazonCodingLast asked Oct 2026

You get a permutation of 1 to n and a window size w. Exactly once, choose a contiguous window of exactly w elements and sort the elements inside it. Return the lexicographically largest array you can end up with.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding