[Solved] slow algorithm contest


Your code looks OK, you might make it faster by checking the words have the same length before the actual sort:

while !STDIN.gets.chomp.empty?
  first_word, second_word = $_.downcase.split
  if first_word.length == second_word.length && 
    first_word.chars.sort == second_word.chars.sort
    puts "YES" 
  else 
    puts "NO" 
  end
end

1

solved slow algorithm contest