⚡️ Tryprepforge
Backend Engineer Senior programming

Given an array of strings, write a function to group anagrams together. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Your task is to return a list of groups, where each group contains all the anagrams from the input array. ### Constraints: - 1 <= strs.length <= 1000 - 0 <= strs[i].length <= 100 - The input contains only lowercase alphabets. ### Examples: 1. Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["bat"],["nat","tan"],["ate","eat","tea"]] 2. Input: strs = [""] Output: [[""]]

Suggested Answer

Practice More Questions Like This

Generate unlimited interview questions with structured answers, code runner, and AI-powered walkthroughs.

No credit card required

More Backend Engineer Interview Prep

Link copied to clipboard