```
class Solution(object):
def findNthDigit(self, n):
"""
:type n: int
:rtype: int
"""
from bisect import bisect_left
nums = [9 * 10 ** i * (i+1) for i in range(10)]
for i in range(1, 10):
nums[i] += nums[i-1]
pos = bisect_left(nums, n)
theNum = n - nums[pos-1] if pos >= 1 else n
num = 10 ** pos + (theNum-1) // (pos+1)
return int(str(num)[(theNum-1) % (pos+1)])
```