Leetcode 686 Solution
This article provides solution to leetcode question 686 (repeated-string-match)
Access this page by simply typing in "lcs 686" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/repeated-string-match
Solution
class Solution {
public:
int repeatedStringMatch(string A, string B) {
string res;
while (res.size() < B.size())
res += A;
if (res.find(B) != string::npos)
return res.size() / A.size();
res += A;
return res.find(B) != string::npos ? res.size() / A.size() : -1;
}
};