logo
Interview
    Interview Guide
    Coding Problems List
Sponsored: Coursera
Problems

Anagrams

Problem

Given an array of strings, return all groups of strings that are anagrams.

Example

Given ["lint", "intl", "inlt", "code"], return ["lint", "inlt", "intl"].

Given ["ab", "ba", "cd", "dc", "e"], return ["ab", "ba", "cd", "dc"].

Note

All inputs will be in lower-case.

Solution

Sort each string, anagrams should have the same sorted string.

Online Judge