Given two strings str1
and str2
, determine if str2
is an anagram of str1
and return true
if it is, and false
otherwise.
An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. For example, the words listen
and silent
are anagrams because they use the same letters with the same frequency, but in a different order.
str1
: A stringstr2
: A stringInput: str1 = "abcd", str2 = "dcba"Output: trueExplanation: Both strings contain the same characters with the same frequency in different orders.
Input: str1 = "hello", str2 = "bello"Output: falseExplanation: The strings do not contain the same characters.
Input: str1 = "listen", str2 = "silent"Output: trueExplanation: Both strings contain the same characters with the same frequency in different orders.
str1.length
, str2.length
<= 1000str1
and str2
consist of lowercase English letters onlyGiven two strings str1
and str2
, determine if str2
is an anagram of str1
and return true
if it is, and false
otherwise.
An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. For example, the words listen
and silent
are anagrams because they use the same letters with the same frequency, but in a different order.
str1
: A stringstr2
: A stringInput: str1 = "abcd", str2 = "dcba"Output: trueExplanation: Both strings contain the same characters with the same frequency in different orders.
Input: str1 = "hello", str2 = "bello"Output: falseExplanation: The strings do not contain the same characters.
Input: str1 = "listen", str2 = "silent"Output: trueExplanation: Both strings contain the same characters with the same frequency in different orders.
str1.length
, str2.length
<= 1000str1
and str2
consist of lowercase English letters onlyconsole.log()
statements will appear here.