Count Digit Occurrences That Divide the Original Number
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Other
### Problem
For positive integer num, count the decimal digit occurrences whose values divide the original num exactly. The input contains no zero digit, and repeated qualifying digits each contribute to the count.
```cpp
class Solution {
public:
int countDigits(int num);
};
```
### Examples
**Example 1:**
```text
Input: num = 222
Output: 3
Explanation: Each of the three digit 2 occurrences divides 222.
```
**Example 2:**
```text
Input: num = 135
Output: 3
Explanation: The number is divisible by 1, 3, and 5.
```
### Constraints
- `1 <= num <= 10^9`.
- No decimal digit of num is 0.
### Clarifying Questions
- Are repeated qualifying digits counted more than once? Yes, once per occurrence.
- Is divisibility tested against the whole original number? Yes.
- Can the input contain a zero digit? No; that is excluded by the constraints.
```hint Check the boundary
Distinguish counting digit occurrences from counting distinct digit values.
```
Overview: Count decimal digit occurrences that divide the original positive number exactly, counting repeated qualifying digits separately.