Skip to content

Instantly share code, notes, and snippets.

@dyoung522
Last active September 12, 2016 17:50
Show Gist options
  • Save dyoung522/290c35a19c488c504d5a to your computer and use it in GitHub Desktop.
Save dyoung522/290c35a19c488c504d5a to your computer and use it in GitHub Desktop.
Technical Interview Questions

Technical Interview Questions

General

  • In as much detail as you like, explain what happens when I type "google.com" into my browser's address bar and press enter.
  • Explain the difference between dynamic vs. static programming languages? What are the advantages/disadvantages of each?
  • What's something you love/hate about your favorite programming language?
  • What tools do you use for your day to day work? Language, IDEs/editors, version control, build systems, provisioning, etc.?
  • What's the difference between an class vs. an object?
  • What is inheritance? What are some alternate ways to reuse logic without using it? What are some downsides to it?
  • What is polymorphism? Why is it useful?
  • Describe the differences between unit and integration testing. When do you favor one or the other?
  • Describe the REST protocol in as much detail as possible
    • What's the difference between PUT and POST?
    • What is API versioning, why is it useful and how might you implement it?

Design

  • Describe MVC pattern

  • Describe any design patterns you're familiar with. Discuss the tradeoffs.

  • Explain what "refactoring" means to you?

    • How do you go about refactoring?
    • What are common refactorings you reach for?
    • What signals (smells) do you look for to evaluate whether something needs to be refactored?
    • Are there times when you should/should not refactor something?
  • Let's say we have a "customer charging service" that needs to interact with our credit card gateway. The gateway has a testing playground, however, it's sometimes offline causing the current tests to break frequently, or timeout and fail when under heavy load. How would you improve this?

OOP Animal Kingdom

Model the Animal Kingdom as a class system, e.g. for use in a Virtual Zoo program.

We're looking for their basic grasp of Object Orientated Programming, the animal kingdom is already broken down into scientific classes, so the hope is they would pick up on the parallels and use them:

  • Kingdom
  • Phylum
  • Class
  • Order
  • Family
  • Genus
  • Species

Character Count Problem

Write a function called count_chars that accepts a string and returns the number of occurrences of each character in the string.

count_chars('cat') # => {a: 1, c:1, t: 1}
count_chars('hey there') => # {e: 3, h: 2, r: 1, t: 1, y: 1}

One possible solution:

def count_chars(string)
  chars = {}
  string.each_char do |char|
    c = char.downcase # count upper and lowercase as the same letter
    chars[c] ||= 0
    chars[c] += 1
  end
  chars
end

puts count_chars(ARGV[0] || "hello").sort.to_h.inspect

Formatting Output Problem

Write a program that prints out a properly formatted grade-school multiplication table up to 12x12

One possible solution:

(1..12).each do |x|
  (1..12).each do |y|
    printf "%03s ", (x*y)
  end
  puts
end

We're looking to see how comfortable they are with formatting output when necessary, using tools like printf

Simple Text Search Problem

Let's say we have a large legacy static website. All content is in the "html" directory and contains many subdirectories of varying depths with .html files. The product team has asked that we find any phone number references and ensure they are in a consistent format given they presently aren't. Assuming phone numbers are presently formatted as "555-5555" or "555-555-5555" or "(555) 555-5555" how would you obtain a list of all files that need to be changed?

Just trying to see if they are comfortable with regular expressions and command line tools like grep

Hamming Distance Problem

Write a function to calculate the Hamming difference between two strings. This distance is the comparison of how many differences are present in the two. For example, given the following strings:

GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT
^ ^ ^  ^ ^    ^^

The Hamming distance would be 7.

Here's are some sample test cases:

"A", "A"                          # => 0
"A", "G"                          # => 1
"AG", "CT"                        # => 2
"AGG", "AGA"                      # => 1
"GATACA", "GCATAA"                # => 4
"GGACGGATTCTG", "AGGACGGATTCT"    # => 9

One possible solution:

def self.compute(left_strand, right_strand)
  (0..left_strand.length).count do |i|     
    left_strand[i] != right_strand[i]      
  end                                      
end                                        

Bricks Problem

Implement a function called enough_bricks? that calculates if we can lay bricks out to the desired goal. We have two types of bricks: "big" and "small". Assume big bricks are 5 units wide, and small bricks are one.

Our function should take three arguments: the number of small bricks we have available, the number of big bricks we have available, and our desired goal. Return true or false if the goal is attainable based on the parameters we provide.

enough_bricks?(3, 1, 8) # => true
enough_bricks?(3, 2, 10) # => true
enough_bricks?(15, 2, 12) # => true
enough_bricks?(1, 4, 11) # => true

enough_bricks?(3, 2, 9) # => false
enough_bricks?(2, 3, 3) # => false
enough_bricks?(15, 2, 26) # => false

One possible solution:

BIG_WIDTH = 5
  
def enough_bricks?(small, big, goal)
  # case 1: not enough total bricks       
  total = (big * BIG_WIDTH) + small       
  return false if total < goal            
                                          
  # case 2: not enough small breaks       
  small_needed = goal % BIG_WIDTH         
  small_needed <= small                   
end                                       

Pascal's Triangle

In mathematics, Pascal's triangle is a triangular array of the binomial coefficients. In the Western world, it is named after French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in India, Persia (Iran), China, Germany, and Italy.

The rows of Pascal's triangle (sequence A007318 in the OEIS) are conventionally enumerated starting with row n = 0 at the top (the 0th row). The entries in each row are numbered from the left beginning with k = 0 and are usually staggered relative to the numbers in the adjacent rows. Having the indices of both rows and columns start at zero makes it possible to state that the binomial coefficient appears in the nth row and kth column of Pascal's triangle. A simple construction of the triangle proceeds in the following manner: In row 0, the topmost row, the entry is 1 (the entry is in the zeroth row and zeroth column). Then, to construct the elements of the following rows, add the number above and to the left with the number above and to the right of a given position to find the new value to place in that position. If either the number to the right or left is not present, substitute a zero in its place. For example, the initial number in the first (or any other) row is 1 (the sum of 0 and 1), whereas the numbers 1 and 3 in the third row are added to produce the number 4 in the fourth row.

e.g.

0...                              1
1...                          1       1
2...                      1       2      1
3...                   1      3       3     1
4...                1     4       6      4     1
5...             1     5     10      10     5     1
6...          1     6    15      20     15     6     1
7...       1     7    21     35      35    21     7     1
8...    1     8    28    56      70     56    28     8     1
9... 1     9    36    84    126     126    84    36     9     1

Questions

  1. Provided the first four rows, can the applicant figure out the pattern and complete the 5th row?
  2. Formulate a program which, given a row and a column, calculates it's value.

e.g.

pascal(5,2) // => 10

Ruby/Rails

  • Explain to me the difference between a class and module. Do either support multiple inheritance. Tell me about the difference between a symbol and a string (high level). Can you talk to me about the implementation details of each?
  • How does a GET request to a Rails application become a response?
  • What is CSRF? How does Rails mitigate this sort of attack?

Javascript

  • Describe the this keyword in Javascript
  • Make this work:
[1, 2, 3].duplicate() // => [1, 2, 3, 1, 2, 3]

Trying to see if they are familiar with prototype in JS.:

Array.prototype.duplicate = function() { return this.concat(this); }
  • How do you test your Javascript?
  • What are linters? Why are they useful?
  • How do you organize your Javascript (modules/namespaces?)
  • Explain "hoisting" in Javascript
  • Explain closures and how they are useful
  • Explain event bubbling
  • Explain AJAX
  • Explain Same Origin Policy in relation to Javascript.
    • What are some techniques for working around this limitation?
  • Explain JSONP
  • Explain difference between setInterval and setTimeout?
    • How do you stop a function spawned through setInterval

CSS

  • How can we fix the broken layout in this snippet? See how the side bar is collapsing beneath the articles. The designers would like these two columns to be side by side but it doesn't work at the moment. Can you fix it?
  • What is a "box model" in CSS?
  • In what ways are CSS pre-processors like SASS/Less useful?
  • What are CSS "floats"?
    • If I've floated an element and it's not expanding to the height of its children, how can I fix?
    • What does clearing a float do?
  • Can you explain this selector?
[role=navigation] > ul a:not([href^=mailto]) {

}

Personal

  • What technologies are you excited about and would like to learn?
  • What do you like to do for fun?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment