C# HashSet
\npublic int SmallestRepunitDivByK(int K) {\n    int res = 1;\n    int len = 1;\n    HashSet<int> rests = new HashSet<int>();\n    while(true) {\n        res %=
```\npublic int SmallestRepunitDivByK(int K) {\n    int res = 1;\n    int len = 1;\n    HashSet<int> rests = new HashSet<int>();\n    while(true) {\n        res %= K;\n        if(res == 0) return len;\n        if(rests.Contains(res)) return -1;\n        rests.Add(res);\n        len++;\n        res *= 10;\n        res += 1;\n    }\n}\n```
[]