[C++] From failed solution to a successful one
\n/*\nIntuition: For Example 3: K = 3\nm=\n1\n11\n111\nThis is brute-froce search the anwser. You will encounter overflow soon. What really matter is remainer o
```\n/*\nIntuition: For Example 3: K = 3\nm=\n1\n11\n111\nThis is brute-froce search the anwser. You will encounter overflow soon. What really matter is remainer of mod(m, K);\nFor example, 111 % 3 is same as 21 % 3. How do we get it?   (111 - 3 * someInterger) % 3 is same as 111 % 3. If someInterger = 30, then 21 % 3 == 111 % 3\nThat is a straighforward example why we can find the answer by working on remainder instead of growing 111...1 sequence. \n\nFOr the proposed solution is:\nm=\n1\n2\n0\n\n\n*/\nclass Solution {\npublic:\n    int smallestRepunitDivByK(int K) {\n\t   // N is the remainder, which must be in the range of  between 1%K  and K\n        for (int m = 1, N = 1 % K; N <= K; m = (m * 10 + 1) % K, ++N)\n            if (m == 0) return N;\n        return -1;\n    }\n};\n\n```\nReferece:\n[1] https://leetcode.com/problems/smallest-integer-divisible-by-k/discuss/260887/C%2B%2B-3-lines-O(K)-or-O(1)
[]