Digit Counter - II

You are given a non-negative integer N for each test case. Find and print the number of digits present in N.

The number 0 contains one digit.

Example 1:

Input:

N = 12345

Output:

5

Explanation:

12345 contains five digits.

Example 2:

Input:

0

Output:

1

Explanation:

0 is treated as a one-digit number.

Now Your Turn!

Pick the correct output for the given input

Input:

N = 1000

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 <= N <= 109

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int countDigits(int N) {
// Write your code here
}
};
Test Case

Input:

N