← ALL NOTES
Array

1718. Construct the Lexicographically Largest Valid Sequence

Build the lexicographically largest sequence of length 2n−1 where 1 appears once, each of 2..n appears twice, and the two copies of i are exactly distance i apart. Greedy backtracking: at each…

Loading…