A PlayStation system may compare two user-entered strings, such as a profile label and a reordered version of it. Given two strings, determine whether one is a permutation of the other.
Two strings are permutations if they contain exactly the same characters with the same frequencies, regardless of order. The comparison is case-sensitive, and spaces and punctuation count as characters.
Implement are_permutations(s, t):
s and t.True if t is a permutation of s; otherwise return False.Aim for an O(n) solution using a character-frequency data structure rather than sorting. Let n be the length of the longer input string.
def are_permutations(s, t):