- Don't jump straight into coding, take a few mins to understand the problem and ask any clarifying questions (but not too long).
- Describe your solution to your interviewer and get their thoughts on your solution.
- Think about your algorithm(s) (sorting, divide-and-conquer, dynamic programming/memorization, recursion, etc), including the complexity and approximate runtime. Ask the interviewer if it's ok or if you should think about something more optimized. Then figure out your data structure (Array, Stack, Queue, Hashset/Hashmap/Hashtable/Dictionary, Tree/Binary Tree, Heap, Graph, Bloom Filter, etc) and implement.
- Importantly, after you have finished writing your code, run through it verbally with your interviewer. This is really important at this point. Does it really do what you think it does? Make sure to read what is there, not what you think is there.
- Test your code, put in an input to see what happens. We’re looking for you to find the bugs yourself and fix anything that comes up
- Restate the complexity. Is it the same, or different to your initial thinking based on what you have actually coded up? Make sure you’re thinking about both space and time
- Optimize. Proactively suggest ways to optimize to the interviewer and get their feedback to ensure what you’re trying to do is not overly complex and is correct, then code it up.
Write a simple clean bug free and not over engineering/over complicated code – it's better a simple code that works that an overcomplicated code that doesn’t work – the simple the better.
Key points to be successful in the coding interview:
- Drive the interview; communication is more important than anything so If you need to be quiet to think, that’s great – just let the interviewer know.
- Explored the problem; Talk about what you are doing throughout the interview.
- Reason about your decisions and share your reasoning.
- Think about trade-offs; Find and fix the bugs by yourself.
- Practice under time pressure; Put yourself under time constraints and If possible, have a mock interview with a friend to simulate the interview experience.
- Manage Your Time Effectively; start writing a working solution, then iterate and improve it as you go.
- Break down the problem into logical chunks and solved them
- What format is the word/values given to us?
- How do we define a nearby word?
- Do we need to remove duplicate words/values in the output?
- Does the output need to be sorted?
- Can I expect empty arrays? To avoid edge cases and errors at runtime
- Are they all integers?
- Can I destroy or modify the array?
- Will the array ever be empty?
- What is the expected type of input values?
- Is it ok to return just integers?
- Are there any details I need?
- Are there any restrictions?
- Always discuss pitfalls and trade offs
- Do I know everything I need to?
- Can I identify a pattern by drawing it?
- Iterative or recursive?
- Can I try that approach?
- Will I be able to code this approach?
- How can I improve this approach?
- Ask lots of questions, clarify the problem, make sure you know exactly what they are asking you to do and or solve.
- Think out loud: explain your thought process, explain the different ways you are attempting to solve the problem, you need to verbally map out your solutions so the interviewer can understand your thought process. Also, the more the you talk and explain you approaches, the more the interviewer can provide subtle hints on what they are looking for.
- Lastly, turn your verbal solution, into good, clean, concise, bug free code checking for edge cases and corner cases, and even putting together a manual use case if you have time.
- AlgosMed - Mocking interviews, algorithms, etc
- Cracking the Coding Interview