Problem · String
Check Anagrams
Learn this problemProblem statement
You are given two strings s and t.
Determine whether the two strings are anagrams of each other. Two strings are anagrams if they contain exactly the same characters with the same frequencies, possibly in a different order.
Return 1 if the strings are anagrams, otherwise return 0.
Function
checkAnagrams(s: String, t: String) → intExamples
Example 1
s = "listen"t = "silent"return = 1listen and silent contain the same letters with the same frequencies.
Example 2
s = "race"t = "care"return = 1race and care are anagrams.
Example 3
s = "hello"t = "world"return = 0The two strings do not have matching character frequencies.
Constraints
sandtconsist of printable characters.- The comparison is case-sensitive.