¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Find nth digit

Suhas S Inglés 1 ficha

Fichas del conjunto (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])

Información

Descripción
Fichas sobre Find nth digit, creado por Suhas S el 14/05/2018.
Creado por
Suhas S
Visitas
1
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?