Class Solution
java.lang.Object
g0401_0500.s0440_k_th_smallest_in_lexicographical_order.Solution
public class Solution
extends java.lang.Object
440 - K-th Smallest in Lexicographical Order.
Hard
Given two integers n
and k
, return the kth
lexicographically 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.
Example 2:
Input: n = 1, k = 1
Output: 1
Constraints:
1 <= k <= n <= 109
-
Constructor Summary
-
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findKthNumber
public int findKthNumber(int n, int k)
-