public ArrayList<String> anagrams(String[] strs) {
		ArrayList<String> res = new ArrayList<String>();
		if(strs == null || strs.length == 0) return res;
		
		Map<String, String> sort2orig = new HashMap<String, String>();
		Set<String> sortWords = new HashSet<String>();
		
        for(String str : strs) {
        	String sort = sortWord(str);
        	if(!sortWords.contains(sort)) {
        		if(!sort2orig.containsKey(sort)) {
        			sort2orig.put(sort, str);
        		} else {
        			res.add(str);
        			sortWords.add(sort);
        			res.add(sort2orig.get(sort));
        			sort2orig.remove(sort);
        		}
        	} else {
        		res.add(str);
        	}
        }
        return res;
	}