C++ 4 Lines O(K) Time | O(1) Space
\nint smallestRepunitDivByK(int K) {\n        int r=0;\n        for(int i=1;i<=K;i++)\n        {\n            r=(r*10+1)%K;\n            if(r==0) return i; \n  
```\nint smallestRepunitDivByK(int K) {\n        int r=0;\n        for(int i=1;i<=K;i++)\n        {\n            r=(r*10+1)%K;\n            if(r==0) return i; \n        }\n        return -1;  }\n```
[]