Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    440 - K-th Smallest in Lexicographical Order.

    Hard

    Given two integers n and k, return the <code>k<sup>th</sup></code> 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:

    • <code>1 <= k <= n <= 10<sup>9</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer findKthNumber(Integer n, Integer k)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait