Given two integers n and k, return thekthlexicographically smallest integer in the range[1, n].
Example 1:
Input: n = 13, k = 2
Output: 10
Explanation: The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10.
K-th Smallest in Lexicographical Order
Given two integers
n
andk
, return thekth
lexicographically smallest integer in the range[1, n]
.Example 1:
Example 2:
Constraints:
1 <= k <= n <= 109