Medium · Trie · about 15 minutes
Asked at Google, Bloomberg, Amazon, Meta, Microsoft.
Given an integer n, return the numbers 1..n sorted in lexicographic (string) order, in O(n) time and O(1) extra space.
n
1..n