Valid Anagram 🎒

Given two strings s and t, this function checks if t is an anagram of s, and returns true if it is, and false otherwise.

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once.

πŸ” Example Usage

🟒 Example 1

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

πŸ”΄ Example 2

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

πŸ“ Constraints

  • 1 <= s.length, t.length <= 5 * 10^4

  • s and t consist of lowercase English letters.

Last updated