Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int repeatedStringMatch(string a, string b) {
- int n = a.size(), m = b.size();
- int rep = m / n;
- string s = "";
- for(int i = 0; i < rep; i++) {
- s += a;
- }
- for(int i = 0; i < 5; i++) {
- if(s.find(b) != string::npos) {
- return rep + i;
- }
- s += a;
- }
- return -1;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement