Hackerrank challenge - Dictionaries and Maps
You got it (mostly) right, I'd say. I wouldn't worry about runtime on hackerrank. They're not going to throw massive resources at every piece of code someone uploads. You're basically sharing their server with everyone else, so they're throttling things. Plus, there's just basic network lag.

Still, there's a bug:

N is the number of phonebook entries to read, but after that you should read to the end of input. But your code just reads N times in both cases.

Other things:


The Ruby convention is 2 spaces of indentation. Not 4 spaces, not tabs.
Don't use print and then puts with an empty line; just use puts.
Don't use strip unless you want exactly what it does. Most often, you'll see gets.chomp for input handling. #chomp only strips the trailing linebreak, but leaves other whitespace intact.


And you can shorten the if..else to a ternary:

N = gets.chomp.to_i # make this a constant, because why not
phonebook = {}      # shorter way to write Hash.new

N.times do
  name = gets.chomp
  number = gets.chomp
  phonebook[name] = number
end

until STDIN.eof? do # read to end-of-file (i.e. end of input)
  name = gets.chomp
  number = phonebook[name]
  puts number ? "#{name}=#{number}" : "Not found"
end


However, you could also do something else:

N = gets.chomp.to_i
phonebook = Hash.new { "Not found" } # set a default value for undefined keys

N.times do
  name = gets.chomp
  number = gets.chomp
  phonebook[name] = "#{name}=#{number}" # set the entire output string
end

# Will print the name=number string or "Not found"
puts phonebook[gets.chomp] until STDIN.eof?