Refactor almost everything

This commit is contained in:
2022-08-02 12:21:43 +05:30
parent ccc376aea0
commit cab1180397
39 changed files with 117 additions and 54 deletions

View File

@@ -0,0 +1,27 @@
#include <string>
class Solution {
public:
bool repeatedSubstringPattern(std::string s) {
for (int i = 1; i <= s.size() / 2; ++i) {
std::string sl(s.substr(0, i));
if (s.size() % i == 0) {
bool found = false;
for (int j = 1; j < s.size() / i; ++j) {
if (s.find(sl, sl.size() * j) == sl.size() * j) {
found = true;
} else {
found = false;
break;
}
}
if (found) {
return true;
}
}
}
return false;
}
};