Simple Java Solution Beats 99.05% 5ms
\nPlease upvote if you understood the solution\n\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs) {\n        HashMap<String,List<St
\n**Please upvote if you understood the solution**\n```\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs) {\n        HashMap<String,List<String>> map=new HashMap<>();\n        \n        for(int i=0;i<strs.length;i++){\n            String s1=strs[i];\n            char[] arr=s1.toCharArray();\n            Arrays.sort(arr);\n            String str=new String(arr);\n            \n            if(map.containsKey(str)){\n                map.get(str).add(s1); \n            }else{\n                map.put(str,new ArrayList<>());\n                map.get(str).add(s1);\n            }\n        }\n        return new ArrayList<>(map.values());\n    }\n}\n```\n\nTime Complexity: O(n * klog(k)) since we are sorting k characters n times in the loop.
['Java']