Dsa
Strings
Easy
String Anagram Groups
Given a list of strings, group them by anagrams. Print the grouped anagrams as a list of lists. Each inner list should contain strings that are anagrams of each 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 s (1 <= |s| <= 100).
Output Format:
- Print a list of lists containing grouped anagrams.
Example:
Input:
4
tea
ate
bat
tab
Output:
[['tea', 'ate'], ['bat', 'tab']]
Key concepts
stringsanagramsgrouping
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