JavaScript Solution


  • 0
    S
    var repeatedSubstringPattern = function(s) {
        var len = s.length
        if(len===1) return false;
        var flag = Math.ceil(len/2);
        var temp = s;
        var count = 0;
        var re;
        while(flag){
          count++;
          flag--;
          if(len%count!==0){
    		continue;
          }
          re = new RegExp(s.slice(0,count));
          while(re.test(s)){
            s = s.replace(re,"");
          }
          if(!s) break;
          s = temp;
        }
        return !s;
    };
    

Log in to reply
 

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