Problem title
Difficulty
Avg time to solve

Find Pattern in String - KMP Algorithm
Easy
10 mins
Check Permutation
Easy
15 mins
Print Name and age
Easy
--
Check Permutation
Easy
--
Party Over
Easy
--
Remove All The Palindromes
Moderate
--
All substrings
Moderate
--
Detect Cycle in a Undirected Graph
Hard
50 mins
Delete Leaf Nodes With Value X
Moderate
27 mins
Number Of Pairs With Given Sum
Moderate
39 mins
12

Check Permutation

Difficulty: EASY
Contributed By
Avg. time to solve
15 min
Success Rate
85%

Problem Statement

You have been given two strings 'STR1' and 'STR2'. You have to check whether the two strings are anagram to each other or not.

Note:
Two strings are said to be anagram if they contain the same characters, irrespective of the order of the characters.
Example :
If 'STR1' = “listen” and 'STR2' = “silent” then the output will be 1.

Both the strings contain the same set of characters.
Input Format:
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.
Output Format:
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.
Constraints:
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
Sample Input 1:
2
listen silent
east eats
Sample Output 1:
1
1
Explanation for Sample Output 1:
In test case 1, "listen" and "silent" has same set of characters.

In test case 2, "east" and "eats" has same set of characters.
Sample Input 2:
2
triangle integral
hearts earth
Sample Output 2:
1
0
Explanation for Sample Output 1:
In test case 1, "triangle" and "integral" has same set of characters.

In test case 2, "hearts" and "earth" does not have same set of characters.
Reset Code
Full screen
copy-code
Console