simple c++ solution
\nclass Solution {\npublic:\n    int smallestRepunitDivByK(int k) {\n        if(k%2==0 || k%5==0) return -1;\n        if(k==1) return 1;\n        set<int> hash;
```\nclass Solution {\npublic:\n    int smallestRepunitDivByK(int k) {\n        if(k%2==0 || k%5==0) return -1;\n        if(k==1) return 1;\n        set<int> hash;\n        long long val=1;\n        long long modulo=0;\n        int l=1;\n        while(1){\n            if(val % k==0){\n                return l;\n            }else if(hash.count(val %k)){\n                return -1;\n            }else{\n                hash.insert(val%k);\n            }\n            l+=1;\n            val = val*(10%k) +1;\n            val = val%k;\n        }\n        return -1;\n    }\n};\n```
[]