lc400.第N个数字

 

题目链接

此题与jz044.数字序列中某一位的数字相似。

class Solution:
    def findNthDigit1(self, n: int) -> int:
        digit, start, count = 1, 1, 9
        while n > count:
            n -= count
            start *= 10
            digit += 1
            count = 9 * start * digit
        num = start + (n - 1) // digit
        return int(str(num)[(n - 1) % digit])