- Published on
Structuring the technical interview
So you've went through Neetcode and solved hundreds of Leetcode problems, and you feel pretty confident about solving most mediums and some hards. What now?
Well, there's just one final missing step to go from being a Leetcode monkey to smoothly maneuvering the interview to leave a lasting impression.
In this article, I'll be going over a problem solving framework that helped me pass the Google technical interviews.
This was largely built using a few coding interview rubrics from companies like Google, as well as experiences from other people I've talked to.
Stage 0
This is where you start strong and make this count.
- Have the google doc open and ready.
- Start 45 minute timer and place it somewhere closeby. Pacing is everything!
- Eliminate the nerves. Imagine you're just doing some leetcode with a no-name startup.
- Quick and friendly introduction and begin.
Stage 1: Problem statement
In this stage, you're getting into the flow state and understanding the problem in and out. You should have an idea of how to map input -> output as a human.
- Read the problem carefully
- Clarify input and output format
- Basic clarification questions about problem.
- Be ABSOLUTELY sure you understand the problem before moving on
- Remember, NEVER assume any detail until you clarify it.
- Generate AS MANY normal + edge cases as you can think of.
- Confirm output using intuitive approach with interviewer
- Eliminate the ones the interviewer says you don't need to consider
- Get idea of constraints (e.g. size of n)
Stage 2: Thinking about approaches
You've already done the hardwork of generating all the test cases to ensure your future algorithm will 100% work. This is just where the blood, sweat, and tears you put into Leetcode will come into fruition.
- Walk through your simple test cases and begin brainstorming approaches.
- Always start by mentioning brute force.
- Any approach you mention, include complexity info for both time and space.
- Pause. "Does that make sense?" between each "thought block".
- Emphasize your list of approaches and their fundamental trade-offs.
- Now, pick the most efficient one and write the pseudocode for it.
- Ask your interviewer if it looks good and if you can get started with the coding.
Stage 3: The actual coding
Definitely a little different from spitting out a solution ASAP, contest-style. Your focus is on communication, readability and correctness.
- Now, it's just correctly converting your pseudocode into actual Python.
- Stop using terrible variable naming (e.g.
X,Y,A,N
) and be VERBOSE. - Use good spacing and comments to separate related code. Refactor into functions and helpers.
- Whenever you use some python library (e.g. Counter, deque, cache), explain the internals.
- Important: Dry run your code now with a simple test case and fix bugs.
- Run through the edge cases you came up with too.
- Reiterate the time and space complexity.
- You're now confident in your solution and you ask the interviewer if they're satisfied with it.
- At this point if they're not, you might be cooked. Just pray that they say yes.
Remember, you need to do about a dozen mock interviews using this format to really come off as a natural. Scheduling with random people worked better for me as I need to simulate the nerves as well.
Brush-up topics
As a bonus, here's a quick list you can run through to get a mental picture of the topics you've learned. You might want to drill down on any weak spots.
- Greedy
- Two pointer
- Sliding window
- Hashmap/frequency
- Heap
- Montonic queue
- Quick select
- Intervals
- Sorting
- Merge sort, quicksort, bucket sort, cyclic sort
- Binary search:
- Maximize, minimize, rotated array
- DP
- LCS-type
- 0/1 knapsack
- Graphs
- DFS, BFS
- Dijkstra
- Bellman Ford
- Prims, Kruskals
- Union find
- Topological Sort
- Bipartite matching (coloring)
- Eulerian path
- Backtracking
- Subsets, Combination sum, Permutations
- Trees
- Learn atleast one balanced tree data structure (theory)
- Merkle Trees
- Tries
- Stack, Monotonic Stack
- Linked list and floyd's cycle algorithm
- Arrays
- Prefix sum
- Prime Sieve
- Kadane's
- Boyer Moore voting
- Dutch flag partioning
- Simulation
- Divide and conquer
- Big O of recursive functions (can be tricky)
Practice makes perfect! You really only need at max 2 weeks to iron out this interview routine and review all of the topics. Do a few contests to make sure you can consistently atleast solve 3/4 problems.
If you followed everything outlined here and have decent Leetcode fundamentals, you probably have already bagged the offer.
Now, you can escape the shackles of Leetcode and tread into the world of software engineering!