Valid Anagram
Given two strings s and t, return true if t is an anagram of s, meaning t uses exactly the same characters as s with the same multiplicities.
Open official problem prompt ↗Determine whether one string is a rearrangement of another.
Like checking two bags of Scrabble tiles: dump each out and confirm you have the same letters in the same quantities, regardless of the order you drew them.
- Input
- s = "anagram", t = "nagaram"
- Output
- true
- Why
- Both strings contain three a's, one n, one g, one r, and one m, so their letter counts match.
1 <= s.length, t.length <= 5 * 10^4s and t consist of lowercase English letters