Skip to content

Instantly share code, notes, and snippets.

@kamui-fin
Last active July 16, 2024 16:26
Show Gist options
  • Save kamui-fin/31aff2da10a75b17d5131160da273a17 to your computer and use it in GitHub Desktop.
Save kamui-fin/31aff2da10a75b17d5131160da273a17 to your computer and use it in GitHub Desktop.
Structuring a coding interview

Coding Interview Framework

Stage 0

  • Have google doc open and ready.
  • Start 45 minute timer and place it somewhere closeby.
  • Eliminate the nerves bro. Imagine you're just doing some leetcode with a shitty startup.
  • Quick and friendly introduction and begin.

Stage 1: Problem statement

  • 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

  • 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

  • Now, it's just CORRECTLY converting your pseudocode into actual Python.
  • Stop using your shitty variable naming 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.
    • Also 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.

If you followed everything outlined here and have decent Leetcode fundamentals, you probably bagged the offer. Now you can go outside and touch some grass.

Topics to brush up on before the interview

  • 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
    • topsort
    • bipartite matching (coloring)
    • eulerian path
  • backtracking
    • subsets, combination sum, permutations
  • trees
    • learn atleast one balanced tree data structure
    • merkle trees
    • tries
  • stack
    • montonic stack
  • linked list
    • floyd's cycle
  • arrays
    • prefix sum
    • prime sieve
    • kadane's
    • boyer moore voting
    • dutch flag
  • simulation
  • divide and conquer
  • Big O of recursive functions, don't fuck this up #weak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment