Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
For each string, sort its characters to create a canonical key. Use a hash map where the key is the sorted string and the value is a list of original strings sharing that key. Strings that are anagrams of each other produce the same sorted key.
Anagrams are permutations of the same characters, so sorting them produces an identical string. This sorted form serves as a unique group identifier in the hash map.
Updated Feb 2026