题目描述链接:https://leetcode-cn.com/problems/repeated-substring-pattern/
LeetCode C++求解代码:
class Solution { public: bool repeatedSubstringPattern(string s) { int n=s.size(); for(int i=1;2*i<=n;i++){ if(n%i==0){ bool match=true; for(int j=i;j<n;j++){ if(s[j]!=s[j-i]){ match=false; break; } } if(match){ return true; } } } return false; } };