Your question is Permutation Check for Two Strings. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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):