method to decide if two strings are anagrams
Bug
Your algorithm is not quite correct.  For example:
areAnagrams(&quot;abc&quot;,  &quot;abc&quot;)  -&gt; true  (correct)
areAnagrams(&quot;abc&quot;,  &quot;abcd&quot;) -&gt; true  (wrong)
areAnagrams(&quot;abcd&quot;, &quot;abc&quot;)  -&gt; false (correct)

The problem is that you are checking that the characters in s1 exist with the same frequency in s2.  But there can be characters in s2 that do not exist in s1 and you don't check for those.
An easy way to remedy this would be to check that both strings have the same length.  This plus the frequency check you are already doing should ensure that the strings are anagrams.