FAANG · LeetCode #242
Valid Anagram — three-stage drill
1The ProblemEasy
Valid Anagram
Do two strings use exactly the same letters, the same number of times?
Examples
"cat", "act"→ true"rat", "car"→ false
constraintLowercase letters; anagram = same multiset of characters.
2The PatternTIME O(n) · SPACE O(n)
Arrays & Hashing
Trade space for time: a hash map turns 'have I seen this?' into an O(1) lookup.
Problems using this pattern
3The SolutionRESULT → true
Step through it
count s: 'c' → c = 1
Step 1 / 6
Arrow keys to navigate · escape to reset