BackeasyStrings

Character Array Cohesion Solution

Problem Statement

Given an array of strings, categorize them into groups where each group consists of strings that are anagrams of one another.

Example 1
Input
['cat', 'dog', 'god', 'tac', 'act']
Output
[["["],["'","'"],["c"],["a"],["t"],[","]]

Explanation: The strings 'cat', 'tac', and 'act' are anagrams of each other, as are 'dog' and 'god'.

Example 2
Input
['listen', 'silent', 'enlist']
Output
[["["],["'","'"],["l"],["i"],["s"],["t"],["e"],["n"],[","]]

Explanation: All the strings are anagrams of each other.

Example 3
Input
['a', 'b', 'c']
Output
[["["],["'","'"],["a"],[","]]

Explanation: Since there are no anagrams, each string forms its own group.

Constraints

  • 1 <= total strings length <= 1000
  • 1 <= individual string length <= 100
  • All strings consist of lowercase alphabets.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free