Valid Anagram

Implement isAnagram

Given two strings s and t, return true if t is an anagramAnagramA word or phrase formed by rearranging the letters of another, using all the original letters exactly once. of s, and false otherwise. Both strings consist only of lowercase English letters. Two strings are anagrams of each other only if they contain the exact same letters with the exact same frequency — order doesn't matter.

Example 1:

Input: s = "anagram", t = "nagaram"

Output: true

Example 2:

Input: s = "rat", t = "car"

Output: false

Example 3:

Input: s = "a", t = "ab"

Output: false

+ 15 hidden test cases run on Submit.

Constraints:

  • 1 ≤ s.length, t.length ≤ 5 × 10⁴
  • s and t consist of lowercase English letters only

s =

anagram

t =

nagaram