mirror of
https://github.com/TheAlgorithms/Ruby
synced 2024-12-26 21:58:56 +01:00
Update data_structures/arrays/strings/anagram_checker.rb
This commit is contained in:
parent
3bc81b8195
commit
a93d5cc072
1 changed files with 1 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue