package com.fishercoder.solutions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 49. Group Anagrams
 *
 * Given an array of strings, group anagrams together.
 *
 * For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"],
 * Return:
 * [
 * ["ate", "eat","tea"],
 * ["nat","tan"],
 * ["bat"]
 * ]
 *
 * Note:
 *  All inputs will be in lowercase.
 *  The order of your output does not matter.
 */

public class _49 {

    public static class Solution1 {
        public List<List<String>> groupAnagrams(String[] strs) {
            Map<String, List<String>> map = new HashMap<>();
            for (String word : strs) {
                char[] c = word.toCharArray();
                Arrays.sort(c);
                String key = new String(c);
                if (!map.containsKey(key)) {
                    map.put(key, new ArrayList<>());
                }
                map.get(key).add(word);
            }
            return new ArrayList<>(map.values());
        }
    }
}

@@ -158,337 +158,8 @@
 p;%0A%0A
-/**%0A * 49. Group Anagrams%0A *%0A * Given an array of strings, group anagrams together.%0A *%0A * For example, given: %5B%22eat%22, %22tea%22, %22tan%22, %22ate%22, %22nat%22, %22bat%22%5D,%0A * Return:%0A * %5B%0A * %5B%22ate%22, %22eat%22,%22tea%22%5D,%0A * %5B%22nat%22,%22tan%22%5D,%0A * %5B%22bat%22%5D%0A * %5D%0A *%0A * Note:%0A *  All inputs will be in lowercase.%0A *  The order of your output does not matter.%0A */%0A%0A
 publ

refactor 49