forked from larissalages/code_problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path459.cpp
More file actions
33 lines (31 loc) · 658 Bytes
/
459.cpp
File metadata and controls
33 lines (31 loc) · 658 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Solution {
public:
bool repeatedSubstringPattern(string s) {
string t="";
if(s.size()==1)
{
return false;
}
int n=s.size();
for(int i=0;i<s.size()/2;i++)
{
t+=s[i];
// cout<<t<<endl;
int x=t.size();
if(n%x==0)
{
string res;
for(int j=0;j<n/x;j++)
{
res+=t;
}
if(res==s)
{
// cout<<res;
return true;
}
}
}
return false;
}
};