Skip to content
Onsite

Check for Anagram

EasyP1Coding

Given two strings s and t, return true if t is an anagram of s: it uses exactly the same letters with the same counts, in any order. Otherwise return false.

Example 1

Input
s = "anagram", t = "nagaram"
Output
true

Example 2

Input
s = "rat", t = "car"
Output
false

Example 3

Input
s = "aab", t = "abb"
Output
false
Why
Same letters, different counts.

Constraints

  • 1 <= s.length, t.length <= 5 * 10^4
  • s and t consist of lower-case English letters.

Hints

Run checks the 3 visible tests, Submit all 8.