You are viewing a single comment's thread. Return to all comments →
But it's passing all the tests when i change mg[j] = "" with mg.delete_at(j) in Ruby.
Full code
m,n = gets.strip.split(' ') m = m.to_i n = n.to_i mag = gets.strip.split(' ') ran = gets.strip.split(' ') mg = mag.sort rn = ran.sort ransompossible = true rn.each_with_index do |_, i| wordmatch = false mg.each_with_index do |_, j| if rn[i] == mg[j] wordmatch = true mg.delete_at(j) break end end if !wordmatch ransompossible = false break end end puts ransompossible ? "Yes" : "No"
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
But it's passing all the tests when i change mg[j] = "" with mg.delete_at(j) in Ruby.
Full code