You are given an array of strings. Your task is to group all strings that are anagrams of each other. The groups should be formed in the order of their first appearance in the original array.
Note: The final output will be in lexicographic order.
Example 1
Input: arr[] = ["act", "god", "cat", "dog", "tac"]
Output: [["act", "cat", "tac"], ["god", "dog"]]
Explanation: There are 2 groups of anagrams "god", "dog" make group 1. "act", "cat", "tac" make group 2
Example 2
Input: arr[] = ["no", "on", "is"]
Output: [["is"],["no", "on"]]
Explanation: There are 2 groups of anagrams "is" makes group 1. "no", "on" make group 2.
Sign in to write, run, and submit your solution against the full test suite.