Python O(K) by simulation [w/ Comment]
Python O(K) by simulation \n\n---\n\nImplementation\n\n\nclass Solution:\n    def smallestRepunitDivByK(self, K: int) -> int:\n        \n\n        if (K % 2 == 
Python O(K) by simulation \n\n---\n\n**Implementation**\n\n```\nclass Solution:\n    def smallestRepunitDivByK(self, K: int) -> int:\n        \n\n        if (K % 2 == 0) or (K % 5 == 0):\n            \n            # Quick response on special cases\n            # 11111...1 is always not divisible by 2 and by 5\n            return -1\n        \n        \n        # initialization\n        remainder = 0\n        \n        # scan for each sequence 111...1 with length N\n        for N in range(1, K+1):\n            \n            # update remainder on modulo K\n            remainder = (remainder * 10 + 1) % K \n            \n            if remainder == 0:\n                return N\n            \n```
['Math', 'Simulation', 'Python', 'Python3']