This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
kse-02/benchmark/anagram_check.py
github-classroom[bot] 24600885b9
Initial commit
2023-11-13 12:47:53 +00:00

15 lines
439 B
Python

# Based on https://github.com/AllAlgorithms, python/algorithms/math/anagram_check.py
# function to check if two strings are
# anagram or not
def anagram_check(s1: str, s2: str) -> bool:
if len(s1) == 1 and len(s2) == 1:
return s1 == s2
if len(s1) != len(s2):
return False
# the sorted strings are checked
if ''.join(sorted(s1)) == ''.join(sorted(s2)):
return True
else:
return False