How To Win At A Collaborative Coding Interview


Ben NgScreen Shot 2016-11-04 at 2.31.11 PM is a software engineer at Etsy. He previously worked at Shift, enjoys studying distributed systems and mentors at Hackbright Academy. Follow him on Twitter at @_benng

If you’re interviewing for a software engineering position nowadays, one of the first steps in the interview process will be a phone screen. You and the interviewer will look at the same source code using a collaborative code editor like Coderpad. As an engineer for five years and a Hackbright mentor, I’ve been on both sides of the phone. Here’s my big-picture strategy for tackling these interviews, and some advice from experience.

Problem solving is messy. Embrace it!

“Are you going to charge in empty-handed, or carry a sword and a spool of string?”A good interview question will have a solution that isn’t immediately obvious — one that you aren’t expected to know or recognize immediately. Instead, you discover the solution by identifying and solving smaller subproblems, evaluating multiple approaches, and backtracking from failed attempts. Sometimes you’ll need to make a logical leap, and other times you’ll need to make incremental improvements.

Think of the interview as a labyrinth. There’s an unavoidable component of chance involved, but you can maximize your odds of success by having a strategy beforehand. Are you going to  charge in empty-handed and hope for the best, or are you going to carry a sword and a spool of string?

 Five Steps to Success

1. Work some examples manually

Don’t immediately start writing code. There are two good reasons:

  • You want to make sure your understanding of the problem matches the interviewer’s. Try to think of edge-case examples. For example, do you and the interviewer agree on what number the Fibonacci sequence starts with?
  • If you can’t do something manually, you can’t automate it.

The coding questions that you’ll get in phone screens are usually some form of “given this input, produce this output.” Work out a simple example. Then work out some harder ones. Think about edge cases in the input. What if the numbers were negative? What if the integers were real numbers?

2. Translate your examples into test cases

Print this out for your collaborative-coding phone session

A flow chart for problem-solving. Print it and follow it during your collaborative-coding phone session.

After you’ve worked through a few examples, you’ll develop an intuition for what inputs make the problem easy to solve, and what inputs make it difficult. The solutions for the harder cases tend to build on those for the easier ones, so you’ll arrive at a complete solution more quickly if you start by solving the simple cases. Get familiar with your language’s assert library so that you can quickly translate your worked examples into test cases.

3. Start working on a solution

Run your code against your test cases frequently. Get them to pass, one by one. This has two benefits:

  • You’ll demonstrate progress as each test case passes. The interviewer gets to see you methodically tackle a problem rather than flail around. Plus it’s good for your morale.
  • Should you cause an old test case to break — a regression — you’ll know immediately. That’s when the problem is easiest to fix.

4. Look for ways it won’t work

Once all your test cases pass, think of any other edge cases you may have missed. You have a better understanding now of the problem and the solution, so you may come up with situations where your code won’t work. If you do, go back to step 3. Your interviewer will be impressed with how careful you are, and how readily you admit to discovering flaws in your code.

5. Refine it

“Your interviewer will be impressed with how readily you admit to flaws in your code.”Once you’re confident that your solution is behaving correctly, it’s time to refine it; it’s rare to arrive at the optimal solution for a non-trivial problem on the first try. Analyze your solution’s time complexity, and see if you can do better. Common strategies for improvement are pre-sorting the input, using a special data structure, or using dynamic programming. Use your improved understanding of the problem to simplify your code — an elegant recursive solution might be obvious only in hindsight.

If you get a practical problem — like discovering the primary color of an image — you should talk to the interviewer about how you would operationalize your solution. In other words, what do you need to do before you can ship this code? Common topics are security, performance, scalability, testing, and documentation. For example, will your code work on extremely large input? What if a user uploads a Word document when you expected a jpeg image?

Challenges unique to phone interviews

The interviewer can’t see you

This makes it hard for them to gauge your progress. To combat this, you need to over-communicate what you’re doing, whether that’s talking or typing. Whenever possible, show your work in the collaborative text editor. But sometimes, you’ll get a problem that’s very graphical, and easier to think about on paper. For example, it’s far easier to draw a tree and work out a recurrence relation on paper. Tell the interviewer that’s what you’re doing, so they don’t think you’re spinning your wheels.

You can’t see the interviewer

No vision means you’ll be extra-sensitive to everything you hear. Don’t over-react to it.

  • If you hear typing, it’s not because they’re chatting with their friends or working on something else. A good interviewer will be constantly taking notes; they want to capture exactly what you say and do, so that they can make an objective decision later.
  • If you hear a sigh, it’s probably not because of you. Your interviewer may have received an email that their lunch order was delayed.
  • If you don’t hear anything, it’s because they’re giving you quiet time to think. Don’t presume silence means they’ve written you off.

Using the environment

everything-you-think-you-know-about-thomas-edison-might-be-wrong (1)

“I have not failed. I’ve just found 10,000 ways that won’t work.” — Thomas Edison

Run your code often

Frequently make sure that your code compiles, and that your solution is behaving as expected. Unlike a whiteboard interview, you can actually execute code. So do it, and do it often. Very often — several times a minute isn’t uncommon. It’s a rookie mistake to write a large amount of code and then try to get it working at the end.

Got all that?

“As an engineer it’s not just whether you solve a problem, it’s how you do it. Collaborative coding interviews are a unique opportunity to showcase your technical skills. Don’t be intimidated by the stranger watching your every keystroke. Instead, practice the five-step strategy so you can methodically tackle difficult problems under pressure. Before your interview, refresh yourself on the challenges unique to phone screens, so you’re mentally prepared for what’s to come. Finally, don’t forget to use the environment to your advantage, by frequently running your code as you’re working on it. You’ll be a winner, because as an engineer it’s not just whether you solve a problem, it’s how you do it. 

November 11, 2017
Getting Back into the Corporate World After 10 Years: Meet Dee Li
November 05, 2017
Alumna Spotlight: How Jamie Corley Built TheBridge
October 18, 2017
Incredible Web Apps Built by Female Engineers
October 14, 2017
Meet Seema Ullal: Instructor for Hackbright's Part-Time Prep Course