0386. Lexicographical Numbers
Last updated
Was this helpful?
Last updated
Was this helpful?
https://leetcode.com/problems/lexicographical-numbers
Given an integer n
, return all the numbers in the range [1, n]
sorted in lexicographical order.
You must write an algorithm that runs in O(n)
time and uses O(1)
extra space.
Example 1:
Example 2:
Constraints:
1 <= n <= 5 * 104
It's more like a tricky math problem instead of practical algorithm problem.