A year ago, I began solving problems on LeetCode. 🚀 Since then, I have successfully finished 300+ problems, and here are my thoughts and conclusions about this journey. 💡
I'm a technical leader in an outsourcing tech company. The last time I attempted a job interview was three years ago, with this company. Now, I've decided to update my interview skills, not necessarily to change my current job, but to explore something new. Frankly, I wasn't entirely new to algorithms, but I had never systematically learned them on a daily basis.
My previous interviews were more like improvisations on unfamiliar problems within a one-hour timeframe. Due to this approach, my results lacked consistency, and most of the time I failed. If you find yourself in a similar situation, this article could be helpful, as I aim to provide a plan. 🎯
So, as mentioned earlier, a year ago, I decided to change this situation, gain confidence, and improve as a specialist. I wasn't aiming for FAANG or any specific destination; I just wanted to handle interviews with minimal stress. I didn't set a concrete goal, so I wasn't afraid of failure. It might not be the typical motivational advice, but it worked for me. 💪
Advice 1: Keep it Simple and Light ✨
I can't claim a 100% success rate in coding interviews now, but luck isn't the only factor anymore.
Everyone learns at their own pace; don't compare yourself to those who solve problems faster. There will always be someone better. I'm not the most productive person, and I was unsure where to start learning algorithms. After some research, I found lists of LeetCode patterns that others had compiled and collected. I used one of these lists, but there are many others available that you can find in the google.
Advice 2: Choose a Problem List as Your Guide 📚
All problems have underlying similarities, and people have already categorized them into patterns. Learning these patterns enables you to recognize them during interviews. Therefore, focus on learning patterns rather than how to solve individual problems.
Advice 3: Learn Patterns, Not Problem Memorization 🧩
Surprisingly, the "Easy" problems on LeetCode aren't always easy. In my experience, LeetCode problems can be classified as follows:
Easy level: Problems with simple patterns and common use cases, or even problems lacking a clear pattern.
Medium level: Problems with patterns that require additional techniques or data structures for solving, or problems with non-trivial use cases for simple patterns.
High level: Problems that combine two or more patterns and data structures.
As you can see, without understanding basic patterns, solving "Easy" problems efficiently on LeetCode becomes a challenge, especially when you need to solve them with optimal time and memory complexity. 🤔
I used this list of patterns for my preparation, but you can use another; it's just an example of what it usually looks like. 😊
Here is my top list of patterns that I didn't know, and I would have never arrived at them during an interview. So, if you learn them, it increases your chances of passing the interview. I've ordered them by the number of problems you can solve by learning each pattern: 📈
- BFS/DFS/backtracking - these patterns are amazing; once you understand them, they will stay with you for the rest of your life. Many problems on LeetCode can be solved using these patterns, even problems from the dynamic programming section (not optimally, but still). If you have limited time, focus on learning these patterns – it's your best shot. 🌟
- Search algorithms, including binary search, merge, bucket, divide and conquer, and quick sort. 🔍
- Heap/Priority Queue. This is an interesting data structure that I had only heard about before and didn't know how it worked internally. Since it was entirely new to me, this pattern seemed very useful, especially if it's not available in your programming language. ⚙️
- Trie. Another data structure pattern that's very helpful to know; you definitely can't invent it during an interview. 🌳
I followed this strategy when solving LeetCode problems:
- Read the problem. 👀
- Do not start coding. ❌
- Understand the problem. 🤔
- Do not start coding! ❌
- Examine the constraints. 📋
- Do not start coding!! ❌
- Find the pattern for solving it. 🧩
- Do not start coding!!! ❌
- If you discover a pattern and solution, talk it out loud, and finally, write the code. If not, explore related topics – it might spark an idea; if that doesn't help, proceed to submissions. 💡
As you can observe, the most challenging part is refraining from immediately starting to code a solution.
Advice 4: Find the solution, then code it. 💡👨💻
There will be times when you feel slow and frustrated, but remember that some algorithms are built upon problems that were previously solved by scientists who might have even received Nobel prizes for their work. 🥇🧠
I enjoyed the time I spent solving these problems. Of course, if you don't use it, you quickly forget it. However, I'm confident that if you tackle it once, the next time will be faster. Leave a comment how many problems you already solved on Leetcode, share your strategy, I will really appreciate it. Good Luck! 🚀🍀