Problem 1718 · Medium

Construct the Lexicographically Largest Valid Sequence

Fill the sequence left to right with the largest value that still fits, backtracking when a placement leaves a gap.

Open the interactive visualisation