Trains the technique from
LeetCode 2520Count the Digits That Divide a NumberThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A meter shows a positive whole number reading.
Walk the decimal digits of reading from left to right. A digit carries when the reading divides by that digit with no remainder. A digit equal to 0 never carries, since nothing divides by zero.
Return how many digit positions carry. A digit that appears more than once is counted once for each position it occupies.
Example 1
4620 divides evenly by 4, by 6 and by 2, so those three positions carry. The final digit is 0 and never carries.
Example 2
305 leaves a remainder of 2 when divided by 3, the middle digit is 0 and cannot carry, and 305 divides evenly by 5. One position carries.
Example 3
936 divides evenly by 9, by 3 and by 6, so all three positions carry.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def dividing_digits(reading: int) -> int:public int dividingDigits(int reading)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.