Skip to content

Instantly share code, notes, and snippets.

@lizdenhup
Last active November 10, 2016 23:10
Show Gist options
  • Save lizdenhup/37473e37b95f728a793fb790a19330e0 to your computer and use it in GitHub Desktop.
Save lizdenhup/37473e37b95f728a793fb790a19330e0 to your computer and use it in GitHub Desktop.
Practice interview questions
# 2) Write a function that takes a list of integers and returns the odd numbers.
class Odd
def return_odd(int_array)
odd_ints = int_array.select { |int| int % 2 == 1 }
end
end
  1. What's the difference between a list and a hash? When would you use one over the other?

A list is a type of data structure that

A hash is a data structure which implements an unordered associative array of key-value pairs. One advantage of a hash is that for large n, the average time-complexity of search, insert, and delete operations is in constant-time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment