Simple python solution


  • 0
    H
    class Solution(object):
        def findNthDigit(self, n):
            """
            :type n: int
            :rtype: int
            """
            i = 1
            while n > 9*i*pow(10,i-1):
                n = n - 9*i*pow(10,i-1)
                i += 1
            index = (n-1) % i
            num = (n-1)//i+ pow(10,i-1) 
            return int(str(num)[index])
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.