Update data_structures/arrays/strings/anagram_checker.rb

This commit is contained in:
Vitor Oliveira 2021-03-31 18:38:01 -07:00 committed by GitHub
parent 3bc81b8195
commit a93d5cc072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@
# Complexity analysis:
#
# Time Complexity: O(n log n). Assume that n is the length of s, sorting costs O(n log n), and comparing two strings costs O(n). Sorting time dominates and the overall time complexity is O(n log n).
# Space Complexity: O(1). Space depends on the sorting implementation which, usually, costs O(1) auxiliary space if heapsort is used.
#
def is_anagram(s, t)
return false if s.length != t.length