Skip to content

How to perform well in Interview

  • Step 1: Clarify the problem
  • Repeat it back in your own words
  • Ask about inputs, outputs, edge cases, performance
  • When/if to validate inputs
  • Error handling
  • Step 2: Solution Design
  • DON’T CODE YET
  • Consider some example inputs
  • Explain and discuss possible solutions
  • If none of your approaches will work, explain why
  • FOCUS ON TRADEOFFS
  • DISCUSS TIME AND SPACE COMPLEXITIES
  • Come to agreement w/ interviewer on solution to try before coding
  • Pseudocode if needed
    • But let interviewer know real code is coming
  • ASK: Do you want me to code this now?
  • Step 3: Code
  • TALK THROUGH EVERYTHING
  • Confirm you can use the data structures or libraries you want to use
  • Use data structures generously
    • Existing or of your own creation
  • Step through code with example input
  • Abstract away logic into helper functions that you can write later
    • Later, confirm if the interviewer still wants you to write them
  • Step 5: Test Code
  • REVIEW EVERYTHING
  • Carefully analyze bugs before fixing
  • Step 5: Optimize
  • Increase performance
  • Add error handling
  • Handle edge cases
    • e.g. Empty input, input of size one, input with duplicates
  • Refactor into multiple functions
  • Step 6: Check with interviewer if you’re done

  • 解释 output 的 condition
  • brute force 的 solution
  • 如果是两个 input 的参数,需要看如何在 2 者之间建立关系(映射, 顺序对应)
  • 如何来用画图构建解决的草稿
  • 遍历(正序还是倒序)