Data Structures19 sections · 729 units
Open in Course

Problem - Valid Anagram

Frequency comparison

Given two strings ss and tt, return true if tt is an anagram of ss, and false otherwise. An anagram uses the same characters with the same frequencies, just rearranged.

For example, "listen" and "silent" are anagrams. You're applying a direct application of frequency counting. Compare the frequency maps of both strings.