Leetcode 1064 Solution

This article provides solution to leetcode question 1064 (smallest-integer-divisible-by-k)

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)