思路:各个区间的数值总个数为 (top - bottom)* position_num 1、判断n是其所在区间的第几位:n - 前面区间的总位数,再除以当前区间每位的position_num 2、判断n的val是什么,bottom + n为其所在区间的位数 3、n % position_num为n指向的val的具***置

注意:bottom,top = 0, 10 bottom,top = top, top * 10

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param n int整型 
# @return int整型
#
class Solution:
    def findNthDigit(self , n: int) -> int:
        
        if n == 0:
            return 0
        
        top,bottom = 10,0 # bottom从0开始,不是从1
        p = 1
        
        while n > (top - bottom) * p:
            n = n - (top - bottom) * p 
            bottom, top = top, top * 10
            p += 1
        
        num = n // p
        place = n % p
        return int(str((num + bottom))[place])