Write all the positive whole numbers one after another: 123456789101112131415.... Return the n-th digit of this endless string (counting from 1).
For n = 11 the answer is 0 (the digits are 1 2 3 4 5 6 7 8 9 1 0 1 1 ...).
The starter code writes the numbers until the text is long enough. It is correct but too slow, and uses too much memory, for large n.
Example 1
Input:
nth_digit(11)
Output:
0
Example 2
Input:
nth_digit(3)
Output:
3
1 <= n <= 9 * 10**15No results yet
Run your code to check it against the examples, or submit to run every test.