class Solution:
def findKthNumber(self, n: int, k: int) -> int:
def findk(n,k):
def countsteps(prefix,n):
start = prefix
end = prefix+1
steps = 0
while start <= n:
steps += min(n+1,end)-start
start *= 10
end *= 10
return steps
current = 1
k -= 1
while k > 0:
steps = countsteps(current, n)
if steps <= k:
current += 1
k -= steps
elif steps > k:
current *= 10
k -= 1
return current
return findk(n,k)
标签:findk,数字,Python,current,int,prefix,steps,def,字典
From: https://www.cnblogs.com/DCFV/p/18441559