Skip to content

Commit 79a51a8

Browse files
committed
Runtime: 246 ms (Top 22.18%) | Memory: 480.2 MB (Top 5.04%)
1 parent 2dc2b19 commit 79a51a8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1+
// Runtime: 246 ms (Top 22.18%) | Memory: 480.2 MB (Top 5.04%)
12
class Solution {
23
public:
34
int repeatedStringMatch(string a, string b) {
45
int m=a.size(); int n=b.size();
56
vector<int>d; int mod=n%m; int h=n/m;
6-
7+
78
if(mod==0)
8-
{d.push_back(h); d.push_back(h+1); }
9-
else
9+
{d.push_back(h); d.push_back(h+1); }
10+
else
1011
{ d.push_back(h+1); d.push_back(h+2); }
1112
string s=""; string t="";
12-
13+
1314
for(int i=0;i<d[0];i++)
1415
{s+=a;}
1516
for(int i=0;i<d[1];i++)
1617
{t+=a;}
17-
18+
1819
int i=0; int y1=s.size()-n; int y2=t.size()-n;
19-
20-
20+
2121
while(i<=y1)
2222
{
2323
string x=s.substr(i,n); //cout<<x;
@@ -32,6 +32,6 @@ class Solution {
3232
i++;
3333
}
3434
return -1;
35-
35+
3636
}
37-
};
37+
};

0 commit comments

Comments
 (0)