- One main question will take the bulk of the time. Prep for 20 to 30 minute question
- If the answer isn’t immediately obvious, try to clarify what the question is asking
- Main requirement
- Data structures involved
- Input provided
- Constraints and which you can use or remove
- Give the solution you have even if it’s not the best one and try to work on the best one with them
- You don’t need to find the best solution. Find a solution than not at all
- Think out loud
- Ask clarification questions
- Call out assumptions
- Define inputs, requirements, data structures, constraints, etc. first
- Define edge cases first if you can
- Google TechDev Guide
- Don’t lose time by trying things you know won’t work
- Try to come up with examples you know will break it
- Then fix it after you break it
- More important to solve general case and leave some edge cases
- You can leave edge cases and indicate you know it
- List the edge cases in the beginning
- This will help you testing your possible solutions and approaches
- Try to think of the general case first without the restrictions
- Treat the restrictions as edge cases
- Think of brute force solutions as going through all the possible combinations
- Focus on having a working solution at the end of the interview
- Start with figuring out the exponential solution as the brute force
- Start thinking about just one better level of complexity
- Determine the best achievable complexity as you look at the problem
- Start going from the worst complexity you can implement then once you have it working improve by one level better complexity
- Don’t try solutions you know won’t work
- Block time for yourself before the interview
- If you come up with an idea just say it but don’t implement it
- If you like the idea and want to implement it just ask first if they think that idea is going to work and if they have a counterexample to this
- Show that you can build up to a solution
- Blocking time
- First 5 minutes reading question and asking questions and clarifying ambiguity
- Can the values be negative?
- Can the values be decimals?
- 5-15 minutes coming up with ideas
- 15-30 getting a working solution with good quality code
- Test it and make sure it’s working
- 30-45 optimize the solution and improve complexity
- Book 5 minutes in the end to test and make sure things work
- Don’t write code until you know you can’t improve on the idea you have or can’t move forward right now
- Clean code
- Select more meaningful names that are descriptive for the data structures
- Mention space and time complexity
- The notes are reviewed by committee so you want to make the notes and the code readable
- If you need to initialize something (base case) in the recursion or dp solutions you can mention it as you’re implementing and say this is something you know but will leave to the end
- Questions often have followups
- To see if you can modify the code for changing requirements
- Ask the interviewer if they’re planning to do followups so we can leave time for it
- They will come up with followups if more time is available
- If you get stuck with the task remove constraints
- Always best to come up with your own examples
- You can ask the interviewer to confirm things for you but not rely on them
- If you’re making assumptions about the data, constraints, inputs, requirements, etc. clearly communicate them to the interviewer and tell them the decision you want to make
- Ask for help if you get stuck
- If I don’t remember the syntax or a function signature I can assume a function call or ask him for it if he knows it
- Debug proactively