Skip to content
CampusEduX

Group Anagrams

Mediumjavapythonccppjavascript

Given a list of words, group together the words that are anagrams of each other.

Input Format

The first line contains an integer K, the number of words. Each of the next K lines contains one lowercase word with no spaces.

Output Format

Print one line per group. Within a group, keep the words in input order, separated by single spaces. Order the groups by the first appearance of any of their members.

Related Problems

  • Zero Sum Subarray
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Longest Subarray with Sum K
    Medium · java, python, c, cpp, javascript
    Solve Problem
  • Longest Consecutive Sequence
    Medium · java, python, c, cpp, javascript
    Solve Problem

Input (stdin)

Output

Run your code to see output here...