Dsa
Graphs Dfs
Easy
Group Anagram Connections
You are given a list of strings. Write a program to find the number of distinct groups of anagrams. Two words are in the same group if one can be formed by rearranging the letters of the other.
Input format:
- The first line contains an integer n (1 <= n <= 100), the number of strings.
- The next n lines each contain a string of lowercase English letters.
Output format:
- Output a single integer representing the number of distinct anagram groups.
Example:
Input:
5
eat
tea
tan
ate
nat
Output:
3
Key concepts
graphdfsanagram
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now