RUBY: Check for duplicates in string with only string datatype #algorithm