Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int repeatedStringMatch(string a, string b) {
- int len_a = (int) a.size(), len_b = (int) b.size();
- string tmp = "";
- int rep = len_b / len_a;
- for(int i = 0; i < rep; i++) {
- tmp += a;
- }
- for(int i = 0; i < 5; i++) {
- if(tmp.find(b) != string::npos) {
- return rep;
- }
- tmp += a;
- rep++;
- }
- return -1;
- }
- };
Advertisement
Advertisement