ASAPUtils Logo ASAPUtils
Week 1

Valid Anagram

Valid Anagram solved by counting characters in O(n) rather than sorting, with C++ and JavaScript solutions, the 26-slot frequency array trick, and the Unicode follow-up interviewers like to ask.

The problem

Given two strings s and t, return true if t is an anagram of s — that is, if t uses exactly the same characters as s, the same number of times, in any order.

s = "anagram", t = "nagaram" -> true s = "rat", t = "car" -> false

Related Problems