Java: Group Anagrams

Level : Intermediate
Mentor: Amit Kumar Ghosh
Type : GuidedLab
Points : 10
Duration : 00:35:00

Lab Details

Difficulty Level: MEDIUM

Problem Statement:

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

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.

Input:

strs = ["eat", "tea", "tan", "ate", "nat", "bat"]

Output:

[["eat","tea","ate"],["tan","nat"],["bat"]]

Explanation:

- "eat", "tea", and "ate" are anagrams of each other.

- "tan" and "nat" are anagrams of each other.

- "bat" is not an anagram of any other string.

Self-paced Membership
  • 24+ Video Courses
  • 825+ Hands-On Labs
  • 400+ Quick Notes
  • 125+ Skill Tests
  • 10+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this