Java | TC: O(TotalChars+N) | SC: O(N) | Group by signature of each string
java\n/**\n * Categorize by Count of characters\n *\n * Time Complexity:\n * - O(TotalChars + 26*11*2*N) -> To calculate the count of characters and create the 
```java\n/**\n * Categorize by Count of characters\n *\n * Time Complexity:\n * - O(TotalChars + 26*11*2*N) -> To calculate the count of characters and create the signature using StringBuilder.\n * - O(N) -> to generate final result List of groups.\n * Total Time Complexity = O(TotalChars + N)\n *\n * Space Complexity:\n * - O(26*11*N) -> To save signatures in HashMap.\n *                 We do not need to count the space required for values in HashMap as they will be used in result.\n * Total Space Complexity = O(N)\n *\n * N = Number of strings in strs array.\n */\nclass Solution {\n    public List<List<String>> groupAnagrams(String[] strs) {\n        List<List<String>> result = new ArrayList<>();\n        if (strs == null || strs.length == 0) {\n            return result;\n        }\n        if (strs.length == 1) {\n            result.add(Arrays.asList(strs));\n            return result;\n        }\n\n        HashMap<String, List<String>> groups = new HashMap<>();\n        for (String s : strs) {\n            String signature = getSignature(s);\n            groups.putIfAbsent(signature, new ArrayList<>());\n            groups.get(signature).add(s);\n        }\n\n        return new ArrayList<>(groups.values());\n    }\n\n    private String getSignature(String s) {\n        int[] count = new int[26];\n        for (int i = 0; i < s.length(); i++) {\n            count[s.charAt(i) - \'a\']++;\n        }\n\n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i < 26; i++) {\n            if (count[i] != 0) {\n                sb.append((char) (\'a\' + i)).append(count[i]);\n            }\n        }\n        return sb.toString();\n    }\n}\n```
['String', 'Java']