Trains the technique from
LeetCode 1015Smallest Integer Divisible by KThis 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 machine stamps out numbers written with the digit 1 alone: 1, then 11, then 111, and so on without end.
Return the number of digits in the shortest of these that k divides exactly, or -1 when k divides none of them.
Example 1
The five shortest stamps all leave a remainder, and the sixth is seven times 15873.
Example 2
Every stamp ends in a one, while a multiple of five has to end in a five or a zero, so no stamp can ever divide.
Example 3
A multiple of nine has digits adding to a multiple of nine, so nine stamps are needed, and that number is nine times 12345679.
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 smallest_repunit_div_by_k(k: int) -> int:public int smallestRepunitDivByK(int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.