← All problems
Frequency MapEasy
Valid Anagram
Frequency MapEasy
Step 1 of 8 · Understand
1. Understand the problem
Two strings are anagrams if one can be rearranged to form the other — same characters, same counts, different order. Given strings s and t, return true if t is an anagram of s.
Input
Two strings `s` and `t`, containing only lowercase English letters.
Output
A boolean — `true` if `t` is an anagram of `s`, `false` otherwise.
Examples
input → s = "anagram", t = "nagaram"
output → true
Both strings contain: a×3, n×1, g×1, r×1, m×1.
input → s = "rat", t = "car"
output → false
rat has r×1, a×1, t×1. car has c×1, a×1, r×1. The t is missing and c is extra.
Write your solution above and hit Run tests. Results and tips appear here.