You are given the sequence: 0123456789101112131415...
The 0th digit of this sequence is 0, the 1st digit of this sequence is 1, the 2nd digit of this sequence is 2 and so on. You are given n, find the nth digit of the sequence.
Input: n = 12
Explanation: 0 is the 12th digit of the
Input: n = 20
Explanation: 4 is the 20th digit of the
You don't need to read or write anything. Your task is to complete the function NthDigit() which takes n as input parameter and returns the nth digit of the sequence.
Expected Time Complexity: O(log10(n)) Expected Space Compelxity: O(1)