Interview Prep - Algorithms

Resources for preparing for the algorithm portion of Front End job interviews.

Approach to solution finding

Treat the interview as if it was a collaboration session, and walk through as if you were solving the problem at work. Most importantly talk it out and let the interviewer know your thought process. Use these steps.

  • Understand the question
  • Identify test cases/conditions
  • Design the solution
  • Implement the solution
  • Review the solution
Understand the question

Make sure you are in sync with the interviewer on the expectations. Verify any assumptions you may have.

  • What is the expected behavior
  • What are the inputs? (data structure, units, etc.)
  • What are the outputs?
  • Any special considerations (should the algorithm be stable?)
  • If you don't know the formula or definition of a term, ask.
  • Constraints
Identify test cases/conditions

Depending on the question, consider the standard case as well as boundary cases.

  • Failure cases - Where the expected solution doesn't exist
  • Variety - wildly varying values or all values are the same
  • Number of elements - small or very large set
  • Null conditions
  • Duplicate conditions
  • Boundary conditions
Design the solution

Sketch out the design. If you know there is a more elegant solution, but you only know how to do the brute force approach, acknowledge that.

  • Observations - Any observations, (e.g. At most one letter can exist an odd number of times in a palindrome)
  • Algorithm - Be able to describe the algorithm in steps
  • Code - Sketch out the solution in pseudo code.
  • Complexity - Be able to describe the complexity of your solution.
  • Consider alternatives - Describe why you are rejecting a certain approach.
  • What data structures will be used.
Implement the solution
  • Write the solution
  • Let the interview know of any utility methods that you don't feel need to be coded (e.g. swap)
Review the solution
  • Walk through the solution with a test case showing intermediate output. Walking through, you may have an idea for an improvement or may identify an error. Share these with the interviewer.

  • Address qualities

    • Performance
    • Efficiency
    • Scalability
    • Extensibility
    • Complexity
    • Memory usage
    • Potential improvements

Coaching:

Mock Interviews:

  • Skillbrush - Schedule an online mock interview with an expert
  • Pramp - Peer to Peer online mock interviews

References:

Books - Tech Interviews

Books - Algorithms

Online practice:

Example questions posted by interviewees

Complexity Analysis references

Papers

Videos

  • Tim Roughgarden - Associate Computer Science Professor at Stanford
  • Tushar Roy - Tushar walkt through different problem sets.
  • Krispy Karim - Variety of you tube playlists on Dynamic Programming and other algorithms.

Visualizing Algorithms

  • Algomation - Create algorithms in javascript with visualizations.
  • Visual Go - Step through animations of common algorithms.