Valid Anagram

IF
AlgoAxiomStaff Engineers
JSTS
Easy20 mins

Given two strings s and t, return true if t is an anagram of s, 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.

Examples

Example 1:

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

Output: true

Explanation: Rearranging the letters of "nagaram" produces "anagram".

Example 2:

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

Output: false

Explanation: The letter counts differ — "rat" has a 't' while "car" has a 'c'.

Example 3:

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

Output: true

Explanation: Both strings are identical single characters.

Constraints

  • 1 <= s.length, t.length <= 5 * 10^4
  • s and t consist of lowercase English letters.
Source: Hash Maps pattern — AlgoAxiom
JavaScript
Test Case 1
root = [1, 2, 3]
Test Case 2
root = [1, 2, 3, 4, 5]
Idle