Trains the technique from
LeetCode 3622Check Divisibility by Digit Sum and ProductThis 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 cloakroom prints a positive whole number n on every ticket and stamps the lucky ones. Take the decimal digits of n as they are written, with no leading zeros. Add up those digits to get their total, multiply them together to get their product, and add the total to the product to get the ticket's key.
A ticket is stamped when n is divisible by its key. Return true if the ticket printed with n is stamped and false otherwise.
A ticket whose number contains the digit 0 has a digit product of 0, and 0 counts as divisible by any positive key, so such a ticket is stamped exactly when n is divisible by its digit total.
Example 1
The digits 4, 5, 3 and 6 add to 18 and multiply to 360, so the key is 378. Since 4536 is 12 times 378, the ticket is stamped.
Example 2
The digits 4, 5, 3 and 7 add to 19 and multiply to 420, so the key is 439, and 4537 leaves a remainder of 159 against it.
Example 3
The digits add to 1 and multiply to 0, so the key is 1, and every whole number is divisible by 1.
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 is_stamped(n: int) -> bool:public boolean isStamped(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.