Really easy solution


  • 0
    H
    class Solution {
    public:
        bool repeatedSubstringPattern(string s) {
            string copy(s);
            
            int len = s.length() - 1;
            while (len--) {
                copy += copy[0];
                copy.erase(0, 1);
                if (copy == s) return true;
            }
            return false;
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.