52. Valid Anagram
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, typically using all the original letters exactly once.
Example 1:
Input : s = "anagram" , t = "nagaram"
Output : true
Explanation :
We can rearrange the characters of string s to get string t as frequency of all characters from both strings is same.
Example 2:
Input : s = "dog" , t = "cat"
Output : false
Explanation :
We cannot rearrange the characters of string s to get string t as frequency of all characters from both strings is not same.
Now Your Turn!
Pick the correct output for the given inputInput : s = "eat" , t = "tea"
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= s.length , t.length <= 5*104
- s and t consist of only lowercase English letters