public ArrayList<String> anagrams2(String[] strs) {
    	Map<String,ArrayList<String>> m = new HashMap<String,ArrayList<String>>();
        ArrayList<String> m1 = new ArrayList<String>();
    	
        for(String s:strs){
        	String sorted = sortedString(s);
        	if(m.containsKey(sorted)){
                m.get(sorted).add(s);
        	}else{
        		ArrayList<String> a=new ArrayList<String>();
        		a.add(s);
        		m.put(sorted,a);
        	}

        }
        
        for(Entry<String,ArrayList<String>> e:m.entrySet()){
        	ArrayList<String> a1 = e.getValue();
                    if(a1.size()>=2){
                        m1.addAll(a1);
                    }
                
        }
        
        return m1;
        
    }