Leetcode 1064 Solution
This article provides solution to leetcode question 1064 (smallest-integer-divisible-by-k)
Access this page by simply typing in "lcs 1064" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/smallest-integer-divisible-by-k
Solution
class Solution:
def smallestRepunitDivByK(self, K: int) -> int:
N = 1
ans = 1
m = set()
while True:
r = N % K
if r == 0:
return ans
if r in m:
return -1
N = (N * 10 + 1) % K
ans +=1
m.add(r)