Skip to main content
LeetCode 440, Hard. Topics: Trie. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 26 parametrized pytest cases, and a playground notebook:

Problem

Given two integers n and k, return the k^th lexicographically smallest integer in the range [1, n].

Examples

Constraints

  • 1 <= k <= n <= 10^9

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

NeetCode All.
Last modified on September 7, 2026