Professional Documents
Culture Documents
Photo by Firmbee.com on Unsplash
My quick background
Read the prompt out loud. If you can’t understand how the example input
leads to the output, you don’t understand the problem. Ask the interviewer
for clarification.
Give an example test case or possible edge case input and expected
output. Then ask the interviewer if it’s correct. If it is, you won’t
misinterpret the question.
Talk about the algorithm you’re going to use. Mention out loud what
you’re thinking about and whether your approach will solve the question or
not. Clarify if it’s a brute force method or any other reason why it’s optimal
or not in terms of space and time complexity.
Directly ask your interviewer if they want you to code that solution or
not. They’ll let you know if they’re happy with your approach or if they
want you to give something more optimal where you will think out loud
again.
Yes, half the interview assessment is if you can code a correct and optimal
solution. LeetCode and FAANG interview culture mistaken believe that’s
all it takes to land any offer. Here’s what they’re not telling you.
Code Out loud. Explain out loud what each line of code you’re writing is
doing any what part of the algorithm you mentioned earlier is addressing. If
your algorithm needed to use binary search, then as your coding that
portion, refer back to the algorithm you previously outlined that you are
now coding the binary search portion. Again, reference which part of your
algorithm you outlined as you’re coding it.
Point out what you’re going to code for later. There’s portions of code
you don’t have to look at as you’re writing initially. I’ve been checked on
null input in 25% of my interviews but I don’t always want to waste time
on that if the interviewer is not interested. Put a comment mentioning
//ToDo: Null Checks. You’ll come back to it if they care. If they don’t,
you’ll be happy you saved time.
You’re not done after you finished writing the algorithm you said you
would. We don’t know if it actually works or not with the test cases we
wrote. We don’t know what the interviewer wants you to do now. So ask
instead of assuming what you should be doing. Because different
interviewers care about different things.
Dry run your code against the example inputs. Go through your code
and reference again what portion of code your coding is covering line by
line. Yes, line by line. As you’re going through it, talk about what the state
of the output should look like as you go along. If anything is unexpected,
mention you’re going to fix it and work on it. The rest of the code is invalid
if you’ve made a mistake and you don’t need to discuss further. Repeat
until you’ve fixed all your bugs. Do this for each interviewer given example
test case.
Optimize your code further. If there are bottlenecks in your code, point
them out, explain why the bottleneck is there and what you’re going to do
to optimize them. Talk out loud what you’re thinking and why certain
approaches you’re thinking do or don’t work to optimize the algorithm.
When you do come up with an improved solution, ask again if the
interviewer is happy with that approach and if they want you to implement
it or not.
At some tech companies you’ll be done here. At others, they’ll want a space
and running time analysis.
The mistake everyone makes when asked about space and time
complexity
They answer without showing their work. Never just assert to the
interviewer your algorithm runs in O(logN).
As an example: You iterated through your input using binary search and it’s
the only algorithm you used. Binary search goes through at most O(logN)
elements as it processes elements in the input. What our algorithm does as it
processes is a constant O(1) operation. Therefore, that’s why our running
time is O(logN)