


Input: str1 = “ab” , str2 = “aoba”
Output: True
Explanation : Permutations of first-string str1 i.e. “ab” are [ “ab”, “ba” ].
The substrings of str2 i.e. “aoba” are [ “a”, “o”, “b”, “a”, “ao”, “ob”, “ba”, “aob”, “oba”, “aoba” ].
The string “ba” is present in the list of substrings of string str2.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘T’ lines represent the ‘T’ test cases.
The first and only line of each test case contains two single space-separated strings str1 and str2.
For each test case, print either “True” or “False”.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^4
1 <= M <= 10^4
Strings ‘str1’ and ‘str2’ consists only of lower case letters.
Time limit: 1 second
Check for Base Case i.e if Length of str1 > Length of str2, return false.
One string will be a permutation of another string only if both of them contain the same characters with the same frequency. Consider every possible substring in the long string str2 of the same length as that of string str1 and check the frequency of occurrence of the characters appearing in the two.If frequencies of every letter match exactly, then only str1’s permutation will be the substring of str2.
The steps involved are as follows :
If map1 equals map2
Return True