A Revelation I Had Preparing for Tech Interviews

Mark McWiggins
2 min readMar 20, 2021
Algorithms: you need to study before job interviews

Basically: there’s nothing new under the interview sun.

First of all, I wrote earlier about my experience with Hirevue … the algorithm (for finding whether or not two strings are anagrams) did work and was quite efficient (O(1)) .. but not the simplest one, available with a quick web search:

def isana(a,b):
return sorted(a) == sorted(b)

And I haven’t heard back from this job application; maybe Hirevu’s automation extends to looking for this algorithm exactly? I don’t know, but I rather doubt it.

Another experience I had in a live interview where I was asked to write code:

Figure out whether parentheses are balanced.

I had never seen this one before, but I struggled around for a few minutes and got it working … and generally performed well in the interview. But I didn’t get an offer.

I didn’t realize this one is also a standard trope of interviews … and it’s trivial (which I figured out on the spot with an extra few minutes but didn’t get credit for, apparently):

Use a stack:

PUSH when you get a ‘(‘

POP when you get a ‘)’

Stack should be empty at the end.

And just this morning I was on a tech interview that had as its coding exercise one I must have seen 10 times before: the Fibonacci sequence! With just a bit of fumbling, I had it:

#!/usr/bin/python3def fib(n):
if n <= 0:
return 0
if n == 1:
return 1
return fib(n-1) + fib(n-2)

Clearly this is the recursive version that will overflow the stack on large values … the followup question was “how to improve performance” and the answer is memoization: cache the values as you compute them so you don’t have to create them anew every time the program is run.

I was relaxed and I answered all the questions smoothly with no hesitation … this was for a position I applied posted on Arc, this job site that I somehow got signed up for without realizing it.

After this interview I got an email saying I was “shortlisted” for the position, so we’ll see.

There are many Youtubers promoting their videos on algorithms you need to know for coding interviews with at least one promoting a service, but I didn’t sign up for this, just took advantage of the free ones.

The upshot of all this: get familiar with all of these details before your next tech interview … . it could be the difference between getting the job offer and missing out!

--

--