Skip to content

Valid Anagram

EasyArrays & Hashing
Decode it first. Clues, constraints, pattern and plan before any code.

Two strings are anagrams when one is a rearrangement of the other: same letters, same counts, any order. Given strings s and t, return true if t is an anagram of s.

s = "listen", t = "silent"   →  true
s = "rat",    t = "car"      →  false
s = "aab",    t = "abb"      →  false   (counts differ)

Constraints

  • 0 <= s.length, t.length <= 5 * 10^4
  • s and t contain only lowercase English letters.