GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

Find nth digit

Suhas S Englisch 1 Karte

Karten in diesem Stapel (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])

Informationen

Beschreibung
Karteikarten am Find nth digit, erstellt von Suhas S am 14/05/2018.
Erstellt von
Suhas S
Aufrufe
1
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck