- TL;DR: How to solve algorithmic problem?
- How will you be evaluated during a coding interview?
- My step-by-step plan for algo problem solving
- During the Interview
- Questions: Corner Cases and Constraints
- Tricks and Advice
- 1 Day Before Interview
- Reverse Interview Questions
- More resources
TL;DR: How to solve algorithmic problem?
Read, Repeat, Understand inputs & output with examples, Constraints (edge cases), Ideas (whys, tradeoffs, solve simpler version, imagine helper functions - go from high level to low level), Complexities, Code, Test code. Interact more.
How will you be evaluated during a coding interview?
- Communication - Asking clarifying questions, communication of approach and tradeoffs clearly such that the interviewer has no trouble following.
- Problem solving - Understanding the problem and approaching it systemically, logically and accurately, discussing multiple potential approaches and tradeoffs. Ability to accurately determine time and space complexity and optimize them.
- Technical competency - Translating discussed solutions to working code with no significant struggle. Clean, correct implementation with strong knowledge of language constructs.
- Testing - Ability to test code against normal and corner cases, self-correcting issues in code.
Check
Untitled
My step-by-step plan for algo problem solving
Track time, overall 45 minutes (5 minutes to understand problem, 10 minutes to propose solution, 15 minutes for code, 10 minutes for follow-up question, 5 minutes for open talk)
- Read the problem, repeat it, understand it. Don’t immediately jump into coding!
- Understand inputs and outputs. Draw some examples. Clarify requirements, ask clarifying questions, and understand constraints (edge cases). Example questions: Is it ASCII or Unicode? What is the max value? Is there a difference between capital letters and small letters? Check my questions lists here.
- Think about the solution in your mind. Divide problems into sub-problems. Come up with different ideas (ask whys, think about trade-offs, solve simpler versions, imagine helper functions - go from high level to low level).
- Evaluate the complexity and trade-offs.
- Think of a better alternative solution.
- Debug your code on paper and test with new corner case inputs.
- Write code. Write clean code.
- Write tests. Positive, negative, with edge-cases.
More to read:
During the Interview
- Make a good self introduction at the start of the interview, 1 — 2 min max. Speak with a smile and you will naturally sound more engaging.
- Ask how many problems we will solve? It will help you with time management during interview.
- Track time! 45 minutes (5 minutes to understand problem, 10 minutes to propose solution, 15 minutes for code, 10 minutes for follow-up question, 5 minutes for open talk)
- Follow my step-by-step plan:
- Paraphrase and repeat the question back at the interviewer to make sure you understand the problem right, and to solve the correct problem.
- Clarify assumptions, ask questions (input, output, problem specific, data structure specific questions)
- Run through a simple example, propose a solution, provide complexity analysis, only code if interviewers says OK.
- and so on
- Do not jump into coding right away or before the interviewer gives you the green light to do so.
- Communication and collaboration, problem solving and critical thinking.
- These conversations are meant to be collaborative and show you what it would be like to work with us. Talk like you are talking to friend. I am a problem solver, I am a collaborative team member, take ownership of projects.
- Interview is about evaluating how you think and approach to solution, not about writing 100% working code. Communication/collaboration of thought process and problem solving ability.
- During writing code:
- Explain what you are trying to achieve as you are coding
- Write actual compilable, working code where possible, not pseudocode
- Write clean code, use good variables names (don’t use
a, b, c) - Ask for permission to use trivial functions without having to implement them. E.g.
reduce,filter,min,maxshould all be ok to use - Write simple
asserttest and run simple example - Explain trade-offs and how the code / approach can be improved if given more time
- Ask from interviewers if you are going right direction.
- Do not interrupt your interviewer when they are talking. Usually if they speak, they are trying to give you hints or steer you in the right direction.
- Do not use a lot of programming language built-in functions. If you use it, describe what the method does.
- If stuck: solve simpler version of problem. It is okay to have some code, then optimize it.
- Make it feel like you're on a team. Think aloud.
- Should I handle this case?
- Is it ok I will make this assumption?
- Let's try doing it this way—not sure yet if it'll work.
- Then I'd usually check the code against some edge cases—should we do that next?
- Optimizations: Try different Data Structure: Array, HashMap/Set, Heap, Queue, Stack. LinkedList. Tree. Graph. Trie.
- In the end of the interview ask 2 questions about company, prepare them beforehand.
‣
For example, you need to get a sorted data structure for the problem. You can ask the interviewer if it is okay to create imaginary function.
Questions: Corner Cases and Constraints
- Ask about edge cases (propose edge case). Explain and clarify, DS tradeoff, time and space complexity.
- Questions
- How am I receiving this data?
- How should I output the result?
- What if wrong input is provided?
- Is size, speed, using not build-in library a concern?
- How I would be testing? Tests: Zero, one, two, two to max-1, max, max+1
- Questions to ask
How long/big our input could be?
Empty inputs, null values, 0 length, 1 element input, super long input.
‣
‣
‣
‣
‣
‣
‣
‣
‣
‣
‣
Tricks and Advice
- https://www.techinterviewhandbook.org/coding-interview-prep/ (read all)
- https://www.techinterviewhandbook.org/coding-interview-prep/
1 Day Before Interview
Reverse Interview Questions
- What’s you favorite part of working at ___?
- What does it mean to be successful here, and how do you measure success?
- What would a typical day/week for someone in this role look like? Meetings, working, meetings?
- How the first few month look like at … when you join the team?
- What are the engineering challenges that the company/team is facing?
- How are requirements / expectations communicated? What is the performance review process like?
- How do you test your apps? How releases look like at …? Code review process? Test plan?
- What do you like least? What would you change if you could?
- How do you look at interviews, when tools such copilot or GPT come out?
More questions: https://github.com/yangshun/tech-interview-handbook/blob/main/apps/website/contents/final-questions.md
