Skip to content

Hiring and Interviews

nt3rp edited this page Nov 30, 2012 · 25 revisions

Hiring is very important to small companies. Companies can fail, or succeed, as a result of hiring the wrong person at the wrong time.

As such, we've come up with these guidelines for conducting hiring and doing interviews.

Hiring

[More details required]

Interviews

  • Try to keep the interview to a set amount of time. An hour is a good guideline.
    • 10 minutes for introductions
    • 40 minutes for coding
    • 10 minutes for questions and answers
  • Pick a coding question that flexes a lot of computer science muscles. A good question might involve a few of the following:
    • Recursion
    • Object-Oriented Programming
    • Queues
    • Data Structures
  • Its good to pick a problem that has multiple solutions; it gives the interviewee more opportunity to be creative.
    • Make sure that you understand some of the solutions!
  • Pull the plug if the candidate is bombing the interview. You can always say something like 'This isn't going as I expected'
  • If a candidate is no-go, be sure to site a real reason as to why they aren't a good fit. E.g. "we're looking for folks that understand a language, not framework" or "a solid understanding of these data structures is really important to us"

Example Questions

Question: You have a list of N+1 integers between 1 and N. There is at least one duplicate, but there might be more. Print out a number that appears in the list more than once.
Source: http://www.quora.com/Programming-Interviews/What-are-the-best-programming-interview-questions-youve-ever-asked-or-been-asked Details: If N=3, your list might be 3, 1, 1, 3 or it might be 1, 3, 2, 2. In the first example, you can print '1' or '3' -- you don't have to print both. Answers:

  • O(n^2) time, O(1) space:
    • Compare every number in the list to every other number until you find a duplicate.
  • O(n) time, O(n) space:
    • Iterate through the list and use a boolean array using the integer values as indices.
    • Can be generalized using hashes if not using integers
  • O(n*log n) time, O(1) space:
    • Sort the numbers and compare adjacent pairs (if using something like in-place mergesort)
  • O(n*log n) time, O(1) space (constraint: can't manipulate original list):
    • Binary search for a duplicated number. Go through the list and count the number of integers between 1 and N/2. If the count is greater than the number of possible integers in that range, there is a duplicate in that range. Otherwise, a duplicate must exist in the range of N/2 + 1 to N. Recurse and binary search in the half with the duplicate and keep repeating the process until the duplicate number is found.

Question: You are given two eggs, and access to a 100-storey building. Find the highest floor from which an egg will not break.
Source: http://www.datagenetics.com/blog/july22012/index.html
Details: Both eggs are identical. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is broken, that's it for that egg.
Answers:

  • One egg solutions (illustrative)
    • At most 100 drops - Linear search
  • Many egg solutions (illustrative)
    • At most 7 drops - Binary search
  • Two eggs
    • At most 100 drops - Linear search
    • At most 50 drops - Binary search until egg breaks, then linear search
    • At most 19 drops - Check every ten floors until one egg breaks, then linear search
    • At most 14 drops - Minimize maximal regret
      • Drop the egg from floor n. If it doesn't break, check floor n + (n - 1)
      • n + (n - 1) + (n - 2) + ... + 1 >= 100 -> n (n+1) / 2 >= 100
      • Solving for n, n=13.651~=14. Drop at floor 14, 27, etc.

Additional resources:

Clone this wiki locally