Problem-solving requires two types of mental skills, analytical and creative. I know this sounds very high level So let’s talk about the basic fundamentals what generally I try to follow in day to day professional and personal activities.
- Listen carefully You need to pay very close attention to any information in the problem description. The optimal solution for a sorted vs unsorted array will be totally different so don’t miss anything.
- Brute Force Yes correct, Get the brute force solution as soon as possible, don’t think about the optimal solution. I always catch the first thought that comes to my mind. Don’t think about code, the algorithm just rough idea.
- Optimize Now it’s time to work on your Brute Force with some BUD (Bottlenecks, Unnecessary work and last Duplicated work) techniques.
- Remove the unused information.
- Solve it manually on paper with an example.
- Reverse engineer your thought process. HOW DID YOU DO?
- Make a Time VS Space trade-off. CAN YOU REDUCE-IT MORE?
- Implement Congratulations now you have an optimal solution on paper. The last goal is to write beautiful, modularize code.
If you are trying to solve the problem in interview KEEP TALKING because your interviewer wants to hear how you’re going to approach the problem and it will make the interview more interactive.
Thanks a lot for reading the quick-notes!