Determine whether one string is a permutation of another by comparing character counts.
Given two strings, determine whether one string is a permutation of the other.
Two strings are permutations of each other if they contain exactly the same characters with the same frequencies, possibly in a different order.
Return true if the strings are permutations of each other; otherwise, return false.
s and ttrue if s is a permutation of t, otherwise falseExample 1
Input
s = "abc" t = "bca"
Output
true
Explanation
Both strings contain one a, one b, and one c, so they are permutations of each other.
Example 2
Input
s = "aab" t = "aba"
Output
true
Explanation
Both strings have the same character counts: two a characters and one b character.
Example 3
Input
s = "abc" t = "abd"
Output
false
Explanation
The character counts differ because c appears in s but d appears in t.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.