#242 Valid Anagram
Given two strings s and t, return true if t is an anagram of
s. That is, if t can be formed by rearranging the letters of s,
using every letter exactly once, and false otherwise.
Examples
Input
s = "anagram", t = "nagaram"Output
trueBoth strings contain three a's, one n, one g, one r, one m.
Input
s = "rat", t = "car"Output
falseThe letter counts differ. There's no t in "car".
Constraints
1 ≤ s.length, t.length ≤ 5 × 10⁴s and t consist of lowercase English letters
The explainer is the good part.
Sign in for the full intuition build-up, every approach from naive to optimal with complexity analysis, progressive hints, and commented solutions in Python, JavaScript, and Java. All free.
Want a taste first? Try a free sample: Two Sum or Valid Parentheses.