DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
String

Group Anagrams

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Group Anagrams** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Sort each word as key in hash map **Edge Cases to Consider:** - (1) Empty string in input - (2) Single string - (3) All strings are unique

Examples

Example 1
Input: ["eat","tea","tan","ate","nat","bat"]
Output: [["bat"],["nat","tan"],["ate","eat","tea"]]
Explanation: Classic
Example 2
Input: [""]
Output: [[""]]
Explanation: Single empty
Example 3
Input: ["a"]
Output: [["a"]]
Explanation: Single

Constraints

  • ▪1 <= s.length <= 10^4
  • ▪s consists of printable ASCII characters
  • ▪Solve with optimal space complexity

Watch Out For Edge Cases

  • ▪Empty string in input
  • ▪Single string
  • ▪All strings are unique
Frequently Asked At
AmazonGoogleMicrosoftMetaAdobeFlipkart