400. Nth Digit
Question
Code
class Solution:
def findNthDigit(self, n: int) -> int:
digit = 1
count = 9
while n > digit * count:
n -= digit * count
digit += 1
count *= 10
n -= 1
start = 10 ** (digit - 1)
num = start + n // digit
position = n % digit
return int(str(num)[position])