Group Anagrams when given an array of strings in C++ Example: | Competitive programming questions
Group Anagrams when given an array of strings in C++
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
]
This problem can be solved easily using Maps.
The solution involves 2 steps:
1. Sort the element and make it as the key.
2. Take the value and place it in the key.
Solution:
https://www.prodevelopertutorial.com/group-anagrams-in-c/