950. Count number of odd digits in a number

You are given an integer n. You need to return the number of odd digits present in the number.

The number will have no leading zeroes, except when the number is 0 itself.

Example 1:

Input: n = 5

Output: 1

Explanation: 5 is an odd digit.

Example 2:

Input: n = 25

Output: 1

Explanation: The only odd digit in 25 is 5.

Now Your Turn!

Pick the correct output for the given input

Input: n = 15

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 <= 5000
  • n will contain no leading zeroes except when it is 0 itself.
0
class Solution {
public:
int countOddDigit(int n) {
 
}
};
Test Case

Input:

N