Growing Algorithmic Skills for Coding Interviews

Growing Algorithmic Skills for Coding Interviews

ยท

6 min read

Most computer science students are usually scared of algorithmic coding interviews. The fear is that they will get an unseen coding problem in the interview and they will just go blank and will not be able to solve it.

The solution to this situation is to be able to break the algorithmic problem into pieces and thinking solutions for each of those pieces. But how do we do that? Let's dive deeper into the systematic process with which you can cultivate the skill to break the problem.

Common Myth - Competitive Programming

Some developers have the perception that you can only be good at coding problems if you regularly do competitive programming. This one is just a misconception. CP (Competitive Programming) is just like a sport. If you like to play, you play it. Just like playing soccer makes your physic stronger, doing CP strengthens your algorithmic skills. That's it.

But for coding interviews, you don't need to be a Codeforces Grand Master. You just need to develop problem-solving skills. That is enough for the coding interviews. The reason behind it is that you will be asked logically breakable problems (in 30-40 minutes) during coding interviews which do not require very advanced CP skills.

Practice

As you may already know, the best platform (IMO) to practice coding problems is LeetCode. You don't require to buy premium and I also don't think you should go for paid platforms like algoexpert if you have sufficient time to prepare.

If you have limited time to practice coding before your interview, then you may consider buying LeetCode premium or algoexpert which will give you a set of popular coding interview problems. It will increase your chances in the interview. But note that remembering patterns of popular problems is different from cultivating problem-solving skills.

In the later section of this blog, I will describe a strategy to slowly grow your skills such that you will never be afraid to face any unseen problem.

Which problems should you solve? It is simple. Just open LeetCode's problems section and start solving.

The State of Flow

Have you ever got frustrated because the LC problem is too hard for your current knowledge? In contrast, have you ever felt unproductive because the LC problem is too easy for you? Yes, most of us have been in both of these situations. In both of these situations, we get disheartened and lose interest in practicing the problems.

How do we practice then? Be in a state of flow. What do I mean by that? Solve a problem that pushes you a little bit but for which you already have the tools to solve. How do we know which problem to choose?

  • Start from Easy. Solve 2-3 problems. If you feel it is too easy for you, filter the problem section to the medium tag.
  • Start solving the medium problem. Do you think it is too hard for you? Don't worry. Try to figure out the logic. Can't find out? Nothing to worry about. Open the discussion section of the problem and there you will find many solutions with good comments and explanations. Pick any such solution and look through the explanation and solution. "Ohh my god! I don't understand the implementation. It has something called heapq which I have never heard of." Why worry? Google heapq and read about its usage. Now, you have figured out the solution. Try to implement yourself. Solved! "Ohh God, it took me 2 hours to solve this problem. I am tired". Why? You have actually made a progress. You have understood the explanation. You learned a new module called heapq which will definitely help you in future practice. You might have looked through multiple implementations of solutions from the discussion section. It significantly improved your capabilities since you now know different ways to approach a problem. That is a victory. It is much better than solving 5 easy problems and much much better than being stuck on a very hard problem.
  • Do you feel tired just after solving 1 medium problem? Don't worry. Switch back to easy problems.
  • Repeat this process.
  • Take the help of PepCoding and NeetCode. They have solution videos explaining many LeetCode problems.

The above-described strategy works best in my opinion. You don't force yourself to practice just because you want to prepare for an interview. Understand your mental state while solving the problem and then choose the problem according to that.

This also works for the time of the day as well. For example, if you are practicing problems at night and you are tired, don't start with the medium problem. Instead, start with easy. This is the way in which you can choose problems. Note that you don't have to follow this exact strategy. You can modify this or discover your own which works best for you. The important thing is you have to choose the problem such that you be in a state of flow (Not too easy, not too hard).

Advantages of This Strategy

By following this strategy, you will not see improvement in numbers. You may only be able to solve 1-2 problems in a day. But note that the effectiveness and the quality of the practice that you established are amazing. By following this strategy for a longer period of time (depending on your current knowledge), you will slowly start noticing the below advantages.

  • You have gained good control over data structures implementation because you now know different ways in which a particular data structure can be used to solve a problem.
  • You no longer have fear because you deeply understand that the problem can be broken and it will be easy to solve those broken pieces.
  • You understand the concept behind the particular patterns of problems and you have not just memorized them.
  • ...etc.

LeetCode Hard Problems

Personally, I don't think you need to spend time solving LC hard problems. If you have good command over easy and medium problems, you will be able to solve any kind of problem in a coding interview. I have experienced this. I have not solved any LC hard problems (except weekly contests) but still, I was able to solve all problems in all interviews at TikTok where problems were equivalent to LC hard. So rather than solving LC hard problems, solve as many medium problems as you can.

What Next?

Apply for jobs/internships. Got an interview? Congratulations ๐Ÿš€. Attend an interview like a Pro ๐Ÿ˜Ž.

Thank you for reading this blog. Note that the ideas described in this blog are my opinions and you may not agree with them. In such cases, I recommend exploring other options as you like.

I (Ashutosh Hathidara) am an artificial intelligence engineer, full-stack developer, and designer. I can be reached via:
Email:
Twitter: @ashutosh_1919
Github: @ashutosh1919
Discord: DevSense
LeetCode: @layman_brother

Did you find this article valuable?

Support Ashutosh Hathidara by becoming a sponsor. Any amount is appreciated!

ย