GoConqr has a new look! Let us know what you think.

Flashcards

Find nth digit

Suhas S English 1 card

Cards in this deck (1)

  1. 1Input: 11 Output: 0 Explanation: The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10.class Solution:
    def findNthDigit(self, n: int) -> int:
    first, length, size = 1, 1, 9
    while n > length * size:
    n -= length * size
    length += 1
    first *= 10
    size *= 10
    first += (n-1)// length
    word = str(first)
    return int(word[(n-1)%length])

Information

Description
Flashcards on Find nth digit, created by Suhas S on 14/05/2018.
Created by
Suhas S
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?