mirror of
https://github.com/TheAlgorithms/Ruby
synced 2025-01-15 03:43:22 +01:00
31 lines
559 B
Ruby
31 lines
559 B
Ruby
|
# Challenge name: Is anagram
|
||
|
#
|
||
|
# Given two strings s and t , write a function to determine
|
||
|
# if t is an anagram of s.
|
||
|
#
|
||
|
# Note:
|
||
|
# You may assume the string contains only lowercase alphabets.
|
||
|
#
|
||
|
# Follow up:
|
||
|
# What if the inputs contain unicode characters?
|
||
|
# How would you adapt your solution to such case?
|
||
|
#
|
||
|
# @param {String} s
|
||
|
# @param {String} t
|
||
|
# @return {Boolean}
|
||
|
|
||
|
def is_anagram(s, t)
|
||
|
end
|
||
|
|
||
|
s = 'anagram'
|
||
|
t = 'nagaram'
|
||
|
puts(is_anagram(s, t))
|
||
|
# => true
|
||
|
s = 'rat'
|
||
|
t = 'car'
|
||
|
puts(is_anagram(s, t))
|
||
|
# => false
|
||
|
s = 'a'
|
||
|
t = 'ab'
|
||
|
puts(is_anagram(s, t))
|
||
|
# => false
|