Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

strs =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Strings that are anagrams share the same canonical key.

Approach

For each string, build a key (either sorted characters or a 26-count signature). Use a hash map from key to list of strings.

Why it works

All anagrams map to the same key, so grouping by key collects exactly the strings that are permutations of each other.

Code
Loading...
Complexity
Time: O(n * k)
Space: O(n)
Solution
Updated: 2026-02-23

Idea

Strings that are anagrams share the same canonical key.

Approach

For each string, build a key (either sorted characters or a 26-count signature). Use a hash map from key to list of strings.

Why it works

All anagrams map to the same key, so grouping by key collects exactly the strings that are permutations of each other.

Code
Loading...
Complexity
Time: O(n * k)
Space: O(n)