programming-examples/ruby/Data_Structures/unique_characters.rb

11 lines
204 B
Ruby
Raw Normal View History

2019-11-15 12:59:38 +01:00
def unique_characters(text)
visited_characters = Set.new
text.each_char do |character|
return false if visited_characters.include? character
visited_characters << character
end
true
end