Chalarangelo / 30-seconds-of-python

Short Python code snippets for all your development needs
https://www.30secondsofcode.org/python/p/1
Creative Commons Attribution 4.0 International
8.83k stars 1.26k forks source link

Improve is_anagram snippet #244

Closed azanbinzahid closed 4 years ago

azanbinzahid commented 4 years ago
  1. Use regex to filter non-alphanumeric chars faster. See comparison here.
  2. Simply sort the strings and check if they are equal