<jupyter_start><jupyter_text><jupyter_code>s1 = 'fairy tales'
s2 = 'rail safety'
s1 = s1.replace(" ", "").lower()
s2 = s2.replace(" ", "").lower()
O(nlogn)
#print(sorted(s1) == sorted(s2))
def is_anagram(s1, s2):
  ht = dict()
  
  if len(s1) != len(s2):
    return False

  for i in s1:
    if i in ht:
      ht[i] += 1
    else:
      ht[i] = 1
    
  for i in s2:
    if i in ht:
      ht[i] -= 1
    else:
      ht[i] = 1

  for i in ht:
      if ht[i] != 0:
          return False
  return True
print(is_anagram(s1, s2))<jupyter_output>True
{'fraction_non_alphanumeric': 0.1724770642201835, 'fraction_numerical': 0.03853211009174312, 'mean_word_length': 2.309090909090909, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '90054', 'license': 'MIT', 'n_tokens_mistral': 266, 'n_tokens_neox': 251, 'n_words': 64, 'path': 'Anagram.ipynb', 'repo_name': 'fakecoinbase/sweetpandslashAlgorithms', 'size': '545'}