#Whiteboarding Whiteboarding is a big part of technical interviews. Here are some resources for you to practice shared with us via our Whiteboarding mentor, Phil Corliss.
In ruby there's an array intersection operator. Try implementing it yourself using a brute force method with a time complexity of O(n^2), a method that uses hashes in unexpected ways with complexity of O(n) and a sorting solution with complexity of O(nlogn).
2.1.1 :009 > a = [ 1, 3, -4, 5, 6]; b = [2, 3, 4, 6, 77] => [2, 3, 4, 6, 77] 2.1.1 :010 > a & b => [3, 6]
Check out this site if you get stuck.
In ruby there's a group_by method on Enumerable. Try implementing it yourself. Take some time to think on how to implement it. Don't worry if you can't recall the syntax for accepting blocks.
(1..6).group_by { |i| i%3 } => {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}
- Hacking Coding Interview
- A Beginners Guide to Big O Notation
- Five Essential Phone Screen Questions
- Cracking the Coding Interview [Book]