Python solution beating 90%


  • 1
    K
        a=n
        for i in range(1,11):
            if a-9*(10**(i-1))*i>0:
                a-=9*(10**(i-1))*i
            else:
                b=i
                break
        if a%b!=0:
            return int(list(str(10**(b-1)+(a-1)/b))[a%b-1])
        else:
            return int(list(str(10**(b-1)+(a-1)/b))[b-1])

Log in to reply
 

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