easyArrays & HashingPure DSA~12 min
Tag Set Anagram
Two feature-flag label strings are considered equivalent if one is a reordering of the other — same letters, same counts. Decide whether a candidate label is just a permutation of the canonical label.
Problem
Given two strings s and t, return true if t is an anagram of s — they contain exactly the same characters with the same frequencies — and false otherwise.
Input
Two strings s and t (1 ≤ length ≤ 5·10^4), lowercase English letters.
Output
A boolean — true if t is an anagram of s.
Constraints
- 1 ≤ s.length, t.length ≤ 50,000
- Lowercase English letters only
- Different lengths can never be anagrams
Examples
Example 1
Input
s = "listen", t = "silent"
Output
true
Both have one each of l, i, s, t, e, n.
Example 2
Input
s = "rat", t = "car"
Output
false
'r','a' match but 't' vs 'c' differ.