Trains the technique from
LeetCode 3348Smallest Divisible Digit Product IIThis 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 press stamps serial numbers. num is the serial it is about to stamp, written as a string of digits with no leading zero.
The digit product of a serial is what you get by multiplying all of its digits together. A serial is acceptable when it carries no digit 0 and its digit product is a multiple of t.
Return the smallest acceptable serial that is greater than or equal to num, as a string. The answer may hold more digits than num. If no acceptable serial exists at all, return the string "-1".
Example 1
The serial "16" carries no zero and its digit product is 6, which is a multiple of 6. No acceptable serial lies between 15 and 16.
Example 2
A digit product is a product of single digits, so it can never carry the factor 11, and the answer is the string "-1".
Example 3
The factor 49 needs two sevens, and no two-digit serial at or above 99 supplies them, so the answer grows to three digits: "177" has digit product 49.
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 least_serial_reaching(num: str, t: int) -> str:public String leastSerialReaching(String num, long t)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.