440. K-th Smallest in Lexicographical Order Hard

@problem@discussion
#Trie



1/**
2 * [440] K-th Smallest in Lexicographical Order
3 *
4 * Given two integers n and k, return the k^th lexicographically smallest integer in the range [1, n].
5 *  
6 * Example 1:
7 * 
8 * Input: n = 13, k = 2
9 * Output: 10
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.
11 * 
12 * Example 2:
13 * 
14 * Input: n = 1, k = 1
15 * Output: 1
16 * 
17 *  
18 * Constraints:
19 * 
20 * 	1 <= k <= n <= 10^9
21 * 
22 */
23pub struct Solution {}
24
25// problem: https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/
26// discuss: https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/discuss/?currentPage=1&orderBy=most_votes&query=
27
28// submission codes start here
29
30impl Solution {
31    pub fn find_kth_number(n: i32, k: i32) -> i32 {
32        0
33    }
34}
35
36// submission codes end
37
38#[cfg(test)]
39mod tests {
40    use super::*;
41
42    #[test]
43    fn test_440() {
44    }
45}
46


Back
© 2025 bowen.ge All Rights Reserved.