Python solution


  • 0
    S
    class Solution(object):
        def findNthDigit(self, n):
    
            d = 1
            # Find digits of the result
            while n > (9 * 10**(d-1) * d):
                n -= (9 * 10**(d-1) * d)
                d += 1
            index = (n-1)/d
            offset = (n-1)%d
            return int(str(10**(d-1) + index)[offset])
    

Log in to reply
 

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