Search
⌘K

Leetcode 386. Lexicographical Numbers

Generate the integers from 1 to n in lexicographical (dictionary) order under O(n) time and O(1) extra space; the core challenge is to traverse the implicit 10-ary trie of numeric prefixes (iteratively go deeper by multiplying by 10 and backtrack/increment when necessary).


Question Timeline

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

Comments

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