80% beats best solution
\n\n# Approach\n Describe your approach to solving the problem. \nWe have make a vairable n as we know the number only contain 1 ,\nmake a for loop from 1 to k 
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe have make a vairable n as we know the number only contain 1 ,\nmake a for loop from 1 to k then in a variable p make 1,11,and so on till the length of k. \nNow if p % n is equal to 0 then we just return the length else we return -1.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int smallestRepunitDivByK(int k) {\n        int n =0;\n        int p = 0;\n        for(int i=1;i<=k;i++){\n            p = n*10+1;\n            n = p%k;\n            if(n==0){\n                return i;\n            }\n        }\n\n        return -1;\n        \n    }\n};\n```
['C++']