Posted: 22 Feb, 2021
You have been given two strings 'STR1' and 'STR2'. You have to check whether the two strings are anagram to each other or not.
Two strings are said to be anagram if they contain the same characters, irrespective of the order of the characters.
If 'STR1' = “listen” and 'STR2' = “silent” then the output will be 1. Both the strings contain the same set of characters.
The first line contains an integer ‘T’ which denotes the number of test cases. The first and only line of each test case contains two space-separated strings 'STR1' and 'STR2', respectively.
For each test case, return true if the two strings are anagrams of each other else return false. Print the output of each test case in a separate line.
1 <= T <= 100 1 <= |STR1|, |STR2| <= 10^3 Where |STR1| and |STR2| are the lengths of the string 'STR1' and 'STR2' respectively. Time limit: 1 sec