java.lang.Object
g0401_0500.s0440_k_th_smallest_in_lexicographical_order.Solution

public class Solution extends Object
440 - K-th Smallest in Lexicographical Order.<p>Hard</p> <p>Given two integers <code>n</code> and <code>k</code>, return <em>the</em> <code>k<sup>th</sup></code> <em>lexicographically smallest integer in the range</em> <code>[1, n]</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> n = 13, k = 2</p> <p><strong>Output:</strong> 10</p> <p><strong>Explanation:</strong> The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> n = 1, k = 1</p> <p><strong>Output:</strong> 1</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= k <= n <= 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • findKthNumber

      public int findKthNumber(int n, int k)