You are given two strings s and t. Determine whether t is an anagram of s, meaning whether t can be formed by rearranging the characters of s, using every character exactly once.
Return true if the two strings contain exactly the same characters with the same frequencies, and false otherwise.
Examples
Example 1
Input: s = "anagram", t = "nagaram"
Output: true
Explanation: Both strings contain three 'a's and one each of 'n', 'g', 'r', and 'm'.
Example 2
Input: s = "rat", t = "car"
Output: false
Explanation: t contains a 'c', which never appears in s.
Constraints
1≤s.length, t.length≤5⋅104
s and t consist of lowercase English letters only.
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up