Skip to content

Valid Anagram ​

Valid Anagram — LeetCode

Given two strings s and t, return true if t is an anagram of s — i.e. both contain exactly the same characters with the same frequencies.

Approach ​

Obvious approach is to use HashMap to count the occurrences of characters. Another simpler but expensive operation is to sort the strings and check if they are equal

Remarks ​