2022-03-27 18:35:17 +08:00
|
|
|
<p>Given an integer <code>n</code>, return all the numbers in the range <code>[1, n]</code> sorted in lexicographical order.</p>
|
|
|
|
|
|
|
|
<p>You must write an algorithm that runs in <code>O(n)</code> time and uses <code>O(1)</code> extra space. </p>
|
|
|
|
|
|
|
|
<p> </p>
|
2023-12-09 18:42:21 +08:00
|
|
|
<p><strong class="example">Example 1:</strong></p>
|
2022-03-27 18:35:17 +08:00
|
|
|
<pre><strong>Input:</strong> n = 13
|
|
|
|
<strong>Output:</strong> [1,10,11,12,13,2,3,4,5,6,7,8,9]
|
2023-12-09 18:42:21 +08:00
|
|
|
</pre><p><strong class="example">Example 2:</strong></p>
|
2022-03-27 18:35:17 +08:00
|
|
|
<pre><strong>Input:</strong> n = 2
|
|
|
|
<strong>Output:</strong> [1,2]
|
|
|
|
</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li><code>1 <= n <= 5 * 10<sup>4</sup></code></li>
|
|
|
|
</ul>
|