#flashcards/data-structures

Description

Sometimes you want to know the values in an int. Converting to a string is O(n) but that hurts runtime.

The log_10(abs(n)) gives you the number of digits -1

Runtime

O(1)

Pseudocode

digit_at(n, i) :: lambda n, i: (n // 10**(int(math.log10(n)) - i)) % 10