Asked at
Valid Anagram
EasyVerifiedHash MapString~10 min
Given two strings s and t, return true if t is an anagram of s.
An anagram uses every original letter exactly once. Equal length and equal letter counts settle it.
The input arrives as a single object { s, t }.
Examples
in{ s: "anagram", t: "nagaram" }
outtrue
Both strings use the same letters with the same counts.
in{ s: "rat", t: "car" }
outfalse
Different letters, so not an anagram.
Constraints
- 1 ≤ s.length, t.length ≤ 5·10⁴
- s and t consist of lowercase English letters.
Get help
🔑
Sign in to solve
Sign in to write, run, and submit your solution — and to pick up where your iOS flow left off.