C++||Brute  using set||Critical Observation
To understand the approach you can head over to this post \n\nSo,this problem will be done in a brute way where we will check the remainders  (num%k), where num
***To understand the approach you can head over to*** [this post](https://leetcode.com/problems/smallest-integer-divisible-by-k/discuss/1655732/C%2B%2BJavaPython-5-lines-oror-Image-Explain-oror-Beginner-Friendly) \n\n`So,this problem will be done in a brute way where we will check the remainders  (num%k), where num will start from 1,11,111,....so on untill we get the (num%k==0 or simply the num gets divisble by k)`\n\n`If you have  understand the approach how the problem is needed to be done,one problem is still there that we cannot update the num since num can go beyond 64-bit signed integer, so we need to update num%k `\n\n```\nEg:-11%k can be written as ((1%k)*10+1)%k,\n       111%k can be written as ((11%k)*10+1)%k,\n\t   so on....\n```\n\n***Code:-***\n```\nclass Solution {\npublic:\n    int smallestRepunitDivByK(int k) {\n        int num=1%k,sz=1;             //taking num as as the remainer of first possible case of 1 and sz to keep the track of current number of digits \n        set<int> m;                  //to store the remainders\n        while(num){\n            if(m.count(num))        //to check if a repeated remainder is inserted\n                return -1;\n            m.insert(num);\n            sz++;\n            num*=10;               //\n            num++;                 //increasing the number by 1 digit by appending 1\n            num%=k;                //\n        }\n        return sz;               //returning the number of digits when num becomes 0\n    }\n};\n```\n***T.C.:-O(k)***
['Ordered Set']