✅three Simple Java Solutions || ✅Runtime 5ms
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# code1\nRuntime 5ms\n\n```\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs)\n    {\n        HashMap<String , ArrayList<String>> hashmap = new HashMap<>();\n\n        for (String s : strs)\n        {\n            char chars[] = s.toCharArray();\n            Arrays.sort(chars);\n            String s2 = new String(chars);\n            \n            List<String> arr = hashmap.computeIfAbsent(s2, key -> new ArrayList<>());\n            arr.add(s);\n        }\n\n        return new ArrayList<>(hashmap.values());\n    }\n}\n```\n\n# Code2\nRuntime 9ms\n\n```\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs)\n    {\n        List<List<String>> list = new LinkedList<>();\n\n        HashMap<String , ArrayList<String>> hashmap = new HashMap<>();\n\n        for (String s : strs)\n        {\n            char c1[] = s.toCharArray();\n            Arrays.sort(c1);\n            StringBuilder s2 = new StringBuilder();\n            for (char c : c1)\n            {\n                s2.append(c);\n            }\n            List<String> arr = hashmap.computeIfAbsent(s2.toString(), key -> new ArrayList<>());\n            arr.add(s);\n        }\n\n        for(Map.Entry<String, ArrayList<String>> entry : hashmap.entrySet()) {\n            List<String> l1 = new LinkedList<>();\n            for (String s : entry.getValue()){\n                l1.add(s);\n            }\n            list.add(l1);\n        }\n\n        return list;\n    }\n}\n\n```\n\n\n# code3\nRuntime 670ms\n\n```\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs)\n    {\n      List<List<String>> list = new LinkedList<>();\n\n        ArrayList<String> str1 = new ArrayList<>(strs.length);\n\n        for (int i = 0 ; i < strs.length ; i++)\n        {\n            char c1[] = strs[i].toCharArray();\n            Arrays.sort(c1);\n            StringBuilder s2 = new StringBuilder();\n            for (char c : c1) {\n                s2.append(c);\n            }\n            str1.add(s2.toString());\n        }\n\n        for (int i = 0; i < str1.size() ; i++)\n        {\n            List<String> l1 = new LinkedList<>();\n            String temp = str1.get(i).toString();\n            if (temp != "-1") {\n                int index = i;\n                while (index != -1) {\n                    str1.set(index, "-1");\n                    l1.add(strs[index]);\n                    index = str1.indexOf(temp);\n                }\n\n                list.add(l1);\n            }\n        }\n\n        return list;\n    }\n}\n```\n\n## For additional problem-solving solutions, you can explore my repository on GitHub: [GitHub Repository](https://github.com/ahmedna126/java_leetcode_challenges)\n\n\n![abcd1.jpeg](https://assets.leetcode.com/users/images/54abaa5f-db31-440b-9104-9e18facf6608_1693939907.7778165.jpeg)\n
['Hash Table', 'Linked List', 'Java']