1 static int wing=[]() 2 { 3 std::ios::sync_with_stdio(false); 4 cin.tie(NULL); 5 return 0; 6 }(); 7 8 class Solution 9 { 10 public: 11 bool repeatedSubstringPattern(string s) 12 { 13 return (s+s).substr(1,s.length()*2-2).find(s)!=-1; 14 } 15 };
把两个字符串拼起来,掐头去尾,如果原字符串为子串重复序列,则必然能在新序列中找到原序列。