C# Simple Time = Space = O(n) Soln
\n\npublic class Solution {\n    // Time O(n) || Space O(N)\n    public int SmallestRepunitDivByK(int K) {\n        if (K % 2 == 0) return -1;\n        int rema
![image](https://assets.leetcode.com/users/images/15f5f041-2e87-49c6-829b-db6494abf1cd_1606302401.196246.png)\n```\npublic class Solution {\n    // Time O(n) || Space O(N)\n    public int SmallestRepunitDivByK(int K) {\n        if (K % 2 == 0) return -1;\n        int remainder = 0;\n        int count = 0;\n        HashSet<int> set = new HashSet<int>(100);\n        while (true)\n        {\n            remainder = (remainder * 10 + 1) % K;\n            if (remainder == 0) return count + 1;\n            ++count;\n            \n            // seen this remainder before than break the loop\n            if (set.Contains(remainder)) break;\n            // else add this remainder to the set\n            else set.Add(remainder);\n        }\n        return -1;\n    }\n}\n```
[]