BackeasyHashing

String Cluster Formation Solution

Problem Statement

Given an array of strings, categorize them into groups where each group consists of strings that contain the same characters, regardless of their order.

Example 1
Input
["cat","dog","tac","god","good","act"]
Output
[["cat","tac","act"],["dog","god"],["good"]]

Explanation: The strings 'cat', 'tac', and 'act' form one group because they all contain the characters 'c', 'a', and 't'. Similarly, 'dog' and 'god' form another group, while 'good' is in its own group due to its unique character composition.

Constraints

  • 1 <= number of strings <= 100
  • 1 <= length of each string <= 10
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