leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
0459.cpp (427B)
0 class Solution { 1 public: 2 bool repeatedSubstringPattern(const string &s) { 3 string made; 4 for (int i = 1; i <= s.size() / 2; i++) { 5 if (s.size() % i) continue; 6 const string pref = s.substr(0, i); 7 for (int j = 0; j < s.size() / i; j++) 8 made += pref; 9 if (made == s) return true; 10 made.clear(); 11 } 12 return false; 13 } 14 };