Search
⌘K

Leetcode 1718. Construct the Lexicographically Largest Valid Sequence

Construct a length 2n-1 sequence where 1 appears once and each i∈[2,n] appears twice with exactly i indices between its two occurrences, and return the lexicographically largest valid sequence. The core challenge is a constrained placement/backtracking search (try larger numbers first to maximize lexicographic order) under n≤20.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.