classSolution:deffindKthNumber(self,n:int,k:int) ->int: self.nums = []for i inrange(1, 10):#第一位不能为0 self.dfs(i, n)#从第二位开始dfs回溯return self.nums[k-1]defdfs(self,cur,n):if cur > n:#超出则剪枝return self.nums.append(cur) cur = cur *10for i inrange(10): self.dfs(cur + i, n)