problem 49 . help me out where is the error?
List<List<String>> q= new ArrayList();
        boolean ana = true;
        int fre[]=new int[26];
       boolean visit[]=new boolean[strs.length];
       for(int i=0;i<strs.length;i++){
             if(visit[i])continue;           
           List<String> p = new ArrayList();
             String a=strs[i];
           p.add(a);
          for(int j=i+1;j<strs.length;j++){
         if(visit[j])continue;
              String b=strs[j];
            
              
        for(char x:a.toCharArray()){
            fre[x-'a']++;
        }
          for(char x:b.toCharArray()){
            fre[x-'a']--;
        }      
           
           
             for(int u=0;u<26;u++){
                 if(fre[u]!=0){
                    ana= false;
                   
                 }else{
                     
                 }      
                 }
                 
            if(ana){
               p.add(b);
                  visit[j]=true;
            }else{
                
            }
          }
              
           
           
           
           q.add(p);
           
       
    } 
        System.out.println(q);
Comments (0)