Determine whether two strings contain exactly the same characters with the same multiplicities.
Given two strings, determine whether one string is an anagram of the other. Two strings are anagrams if they use the same characters the same number of times, possibly in a different order.
A valid solution should handle repeated characters correctly and return whether the strings match as multisets of characters.
s and t.true if t is an anagram of s.false.Example 1
Input
s = "anagram", t = "nagaram"
Output
true
Explanation
Both strings contain the same letters with the same frequencies.
Example 2
Input
s = "rat", t = "car"
Output
false
Explanation
The strings have different character counts.
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.