Total digits
Basic Accuracy: 33.33% Submissions: 6 Points: 1

Given a number n, count the total number of digits required to write all numbers from 1 to n.

Example 1:

Input: n = 13
Output: 17
Explanation: There are total 17
digits required to write all
numbers from 1 to 13.


Example 2:

Input: n = 4
Output: 4
Explanation: There are total 4
digits required to write all
numbers from 1 to 4.


You dont need to read input or print anything. Complete the function totalDigits() which takes n as input parameter and returns the total number of digits required to write all numbers from 1 to n.

Expected Time Complexity: O(logn)
Expected Auxiliary Space: O(1)

Constraints:
1<= n <=100000