The Process
- Set aside 30 - 45 mins for each question → Only look at solutions if you can’t solve it in that time
- Put away the code → bring out a pen and paper
- Identify what concept the problem is really asking about
- Eg. If it’s a Data Structures question, which data structure is most appropriate here?
- If it’s a sorting question,
- If it’s a dynamic programming question, which sub-problems am I solving again and again?
- Start first by designing an algorithm with pen and paper.
- If you don’t have test cases, create a reasonable number of test cases that should cover the problem scope
- List your assumptions
- If you’re stuck, don’t try to create the most optimal solution right away. A brute force solution is better than no solution → you can always optimize afterward
- Practice thinking out loud! This is super important - Interviewers want to see how you think, and vocalizing your thought process makes this crystal clear.
- Implement your algorithm in your language of choice and test it
- Think about space-time complexity/ areas for improvement