697. Count Zeros in a Number

EasyRecursionRecursion

Given a non-negative integer N, count the total number of zero digits in N using recursion. For example, N = 10300 has three zeros. Extract the last digit at each step and check if it is zero.

Input: A single non-negative integer N (0 ≤ N ≤ 10^18).

Output: A single integer — the count of zero digits in N.

Examples

Example 1
Input: 10300
Output: 3
Explanation: Digits: 1,0,3,0,0 → three zeros.
Example 2
Input: 1234
Output: 0
Explanation: No zeros in 1234.
Example 3
Input: 1000000
Output: 6
Explanation: Six trailing zeros.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →