#C154. Check if Two Strings are Anagrams
Check if Two Strings are Anagrams
Check if Two Strings are Anagrams
Given two strings s1
and s2
, determine if they are anagrams of each other. Two strings are anagrams if one can be rearranged to form the other, which mathematically can be expressed as: \(\forall c, \; count_{s1}(c) = count_{s2}(c)\). In other words, the frequency of each character in both strings must be identical.
The strings may contain any characters, and the comparison is case-sensitive.
inputFormat
The input consists of two lines. The first line contains the string s1
and the second line contains the string s2
. Both strings may include spaces and punctuation.
outputFormat
Print True
if the strings are anagrams of each other, otherwise print False
.
listen
silent
True