Simple java solution with split()


  • 0
    Z
    class Solution {
        public boolean repeatedSubstringPattern(String s) {
            if(s.length()==0) return false;
            int len = s.length();
            for(int i=1;i<=len/2;i++){
                if((len%i==0)&&s.split(s.substring(0,i)).length==0) return true;
            }
            return false;
        }
    }
    

Log in to reply
 

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