avatarNitin Kishore

Summary

The article provides a strategic approach to using Leetcode for coding interviews, emphasizing daily practice, efficient learning techniques, and the importance of understanding fundamental concepts for career growth in 2023.

Abstract

The blog post "You’re doing Leetcode wrong — Here’s how to get the maximum benefit in 2023" argues that many tech professionals approach Leetcode as a mere repository of interview questions rather than as a tool for continuous skill development. The author, who has successfully leveraged Leetcode to advance their career, suggests that consistent daily or weekly practice is crucial for maintaining coding proficiency and preparing for interviews. The article emphasizes the use of frequency filters to focus on the most commonly asked questions, the importance of not reinventing the wheel by learning from existing solutions, and engaging with the Leetcode community through the discussions tab. It also advises on identifying the right tools for problem-solving, following insightful contributors, developing a personal style, and keeping detailed notes. The author posits that this structured approach to Leetcode can lead to significant career advancements and improved coding practices.

Opinions

  • The author believes that the interview process, which includes coding challenges, is a filter rather than a flawed system, and that complaining about it is unproductive.
  • They suggest that individuals should not rely solely on their past knowledge but should continuously refine their coding skills through regular practice.
  • The article criticizes those who dismiss the importance of learning data structures and algorithms, arguing that such knowledge is foundational and can significantly improve coding efficiency.
  • It is the author's opinion that one should not spend excessive time on a single problem without making progress; instead, one should look up solutions to learn and move forward.
  • The author values the insights and solutions shared by experienced Leetcode users and encourages others to learn from these resources.
  • They advocate for developing a unique problem-solving style and an arsenal of coding tricks to stand out in interviews and improve work code.
  • The author emphasizes the importance of making and reviewing notes to reinforce learning and prepare for interviews effectively.
  • They provide personal anecdotes and career achievements as social proof to validate the effectiveness of their recommended Leetcode strategies.

You’re doing Leetcode wrong — Here’s how to get the maximum benefit in 2023

Now you might be wondering, “ A generic blog post about leetcode? Are people still doing that? Haven’t checked it ages. Do I even need it at this point in my career and where is all this advice coming from? Some random guy?”. Well I’m not special but if you need some sort of social proof, you can scroll to the end of the blog and see that this is the advice that I have formulated and followed, and it’s worked out pretty well for me. So have a read and see if you have in fact, been using leetcode the wrong way.

If you’re in the tech industry, you are quite familiar with the LC grind. Solving numerous problems everyday in hopes that your dream company’s interview process will be composed of the exact same coding question whose index you’ve memorized. You then brush off your acting skills trying to pretend this is the first time you ever saw that problem and suggest an initial brute force approach……because figuring out the most optimal solution right off the bat within 15 minutes, is kind of sus😜. Additionally, it would invite harder problems in the remaining time.

So let create this random dictionary that seems to have no purpose yet, and name it ctr

If you’ve held a tech programming job for at least 2–3 years and worked on anything impactful, you definitely had moments where you realized that the basics mattered and knowing them would have sped up your code by 10-100x. Perhaps you could have achieved your desired result with a simple one-liner instead of multiple hacky codes and function calls. While some may complain that the interview process itself is inherently flawed and you’d never use those data structures or algos in your daily job anyway —

“We should just do away with these coding questions because they don’t determine who is a good programmer or data scientist”

is what they would say. These are the same people who complained when they were being taught algebra in high school. They just don’t get it. Distance yourself from such talk because that is the wrong algorithm to live your life. They live life on a rocking chair, which gives them the illusion of motion, but they aren’t going anywhere in life. Complaining all the time instead of realizing where the root cause of their misery lies is a recipe for ineffectual grandstanding. The system is fine because it is not a system at all. It’s a filter.

There are way more mediocre people than high paying jobs. Of course, they only want the smart ones for such salaries

If you qualify that interview, get the job, and then complain that the process was crappy, you have a leg to stand on, so I’ll hear you out. However, if the simple reality is that you didn’t qualify to meet the standards, you don’t have the justification to complain or ask the other side to lower or change their standards for you. If you got by the filter through sheer luck, well , good for you. If not, sucks to be you. That’s just how life works. Let’s change that, shall we?

Now, if you can muster enough of a growth mindset and get past the denial and the other 4 stages(what does it matter what they are called, you’ve been stuck at stage 1 for ages) you’ll see that you might not be using leetcode the right way.

Denial ain’t just a river in Egypt.

I’ll break this down into the following points and even though they seem intuitive and common-sensical, you might realize that you pretty much, straight up ignored it and brute-forced your way even through this simple procedure.

  1. Use Daily /Weekly
  2. Use the frequency filter
  3. Don’t re-invent the wheel
  4. Discussions Tab
  5. Identify the right tool
  6. Follow the right people
  7. Build your style and arsenal of tricks
  8. Make notes to review

Use Daily /Weekly

For the lack of a better analogy, Leetcoding isn’t like heading to a beauty parlor to put fake stuff on your face before the main event. It’s a daily skin care routine, so that you don’t need to fake anything. Think about this, if you’re on a time crunch and need to speed run through a game, you’d only be able to accomplish that task if you played it consistently for multiple days and enjoyed it.

When opportunity comes knocking, you better be prepared to kick that door down

Repetition and Practice are the key to remembering anything. This works well for programming. When you have slacked off for years and need to find a new job due to circumstances, this will save you. This is your insurance against the job market where you’re available to crush interviews anytime while the competition asks for a 2 week preparation buffer.

You might have been the king of Data structures and algorithms during your senior year, but after 4–5 years in the industry , working on a lot of cool stuff, you clearly won’t have retained the same edge you previously had. Coding isn’t a skill you just learn once. It’s a iterative process of refinement and inclusion. You haven’t learnt everything there is to know about coding because it is constantly evolving. Undergrad courses and bootcamps will only give you the basics. Coding isn’t about knowing the theoretical solution. It it about logically breaking down the problem and arriving at the implementation yourself. Given the turbulent times we currently live in , with the pandemic, recession, lay-offs etc., it pays to be prepared. Literally.

There are 2500 problems on leetcode. You don’t have to solve them all, but it’s great that it’s available for practice . You could spend an hour a day to do 3–5 problems. Once you formed this habit, within a month you would have solved around 120 , and within a year almost 1500 ! That sounds badass 😎. Imagine if you did this last year. Heck, with some new found confidence you could even participate in Weekly contests or branch out to Code Chef and Project Euler for more challenging exercises for your 🧠.

Do you really need a Netflix special to get on this train, like how people suddenly are into Chess after Queen’s Gambit? Silicon Valley won’t get you there. You need to put in conscious effort on a daily or weekly basis depending on your life schedule. Don’t stop doing it after you found a job, and if you are currently looking for a job —

Use the frequency filter

This is a no-brainer. The central-limit-theorem does not miss. The 150 most frequently asked questions, cover almost every topic and algorithm you’d need to know to solve the rest 2500 problems. If you use this as your training set, you will be able to generalize and solve for any other variant of the problem by combining concepts . This is your skill tree. Is it really that much to overwhelm you, or does it seem doable within a year?

Get some of the smaller ones out of the way first

You will obviously have strengths and weaknesses. Try to improve your strengths and compensate for weaknesses. You’ll probably look at company specific questions if needed. Facebook might focus on Graphs, Amazon might focus on Tries and Arrays. When the day comes, depending on the team, the kind of questions they ask can be completely different. If you go by the frequency filter, you will cover everything and be ready for harder variants of the different categories and new problems. If you do come across a completely new problem during your learning phase —

Don’t re-invent the wheel

Some of you might have scoffed at the previous point when I mentioned solving 3–5 problems within an hour. I wasn’t kidding. If a problem is taking you 50 minutes, you clearly have no clue what you’re doing. This is a learning phase where you don’t need to prove yourself to anyone. If you don’t have a concrete idea in your head 5 minutes after reading the problem, you don’t know how to solve it. If you don’t have a map, you’ll keep wandering aimlessly. Stop doing that ! What do you expect will happen if you throw more time at it ? You’ll magically devise and invent a new algorithm that uses 15 if conditions, for loops and some arrays and strings logic?

I don’t think you have the facilities for that big man

If you can’t think of a solution, just look at it. There is probably a simpler method or algorithm to solve that and you aren’t aware of it. Don’t spend more than 20 minutes on a problem that you can’t solve. Learn from it instead. Understand how to solve it . Better men and women than you have spent their entire careers devising algorithms that solve a particular use-case or problem variant. You CANNOT do that in 15 minutes!

You’re not Donald Knuth

You’re not that guy. So don’t beat yourself up over it. If you don’t know how to solve it with everything you’ve learnt so far, this is a new learning opportunity. Add a new tool to your bag of tricks. What you learn now from this obstacle, will clear multiple roadblocks, up ahead in your path. Don’t be stuck at the first attempt

PRO-TIP : Don’t just look at the solution. Internalize it. Run it on a local IDE like PyCharm and debug each line of the code and look at what it does for various test case inputs. Write your thoughts as comments.

If you specifically want to learn every algorithm first and then give practice a shot, I wouldn’t recommend it because you learn more through hands on experience on the job or as mentioned above. If you still insist, I’d recommend the following YouTube channels for their visualization and example based explanations

And for interview prep and some support for getting into coding, you can try

And for you Visual Learners who need to understand through animations, here’s a pretty cool free resource called Visual Algos

Personally, I find animations to be a pretty effective learning aid

Sometimes the same problem can have multiple solutions or the same solution can be implemented in a more efficient and optimal manner. that is why you need to go to the —

Discussions Tab

This is a haven of experienced individuals where you will find tried-and-tested methods that noble souls in the leetcode platform have shared. Thanks to millions of people actively going through them and suggesting improvements in the comments, the best and clever solution posts are usually ranked at the top with titles like “Python O(n) and beats 99.98%” or “Simple one-liner in Python”. Click on those golden nuggets of coding wisdom!

In addition to that you will find more innovative ways to mix interesting ideas not just from algorithms but also other fields. What you need to soak up is not just the solution but also the thought process of the programmers and how they either frame or divide the problem into easier tasks.

Sometimes I’ve even found clever ways of using additional packages like functools, numpy, scipy etc., within these posts that I was able to adopt into my work. You can port solutions across languages as well if you look at the comments in the posts.

Apart from problem specific discussions, you should also check out the general discussion forums and posts that have every information you need about a certain sub topic. Bookmark such links. Here are some of mine

Even if you amass all this knowledge, when the time comes and you’re facing a problem, either on leetcode or at work, you need to —

Identify the right tool

As you saw above in the frequency filter part, you need to have multiple tools in your utility belt. The same problem can be solved using multiple approaches. You need to understand what the question really means. Is this a recursion or a dynamic programming problem? Is this trees or Graph traversal? If you only have a hammer, every problem will look like a nail. You need to identify what the problem actually calls for, which tool to pick and what order to use them in.

Every time you use a roundabout way and complicate a problem, this guy appears and it’s embarrassing

Here are some tips to get you started . You should be reactive to problem statements and come up with some initial ideas and test your hypothesis.

  • Finding out if a path exists? DFS
  • Finding the shortest path? BFS
  • Cycle detection (linked list, array)? Floyds method
  • Finding missing/repeated numbers? Gauss summation formula or Bitwise operations
  • Hash maps: too general to say, lots of uses. ie., counting occurrences of characters in a string, keeping track of index where a character last appeared, etc.
  • Heap: priority queue for certain graph algorithms, when you need quick access to highest/lowest element already processed, but may need to access more than one element.

Keep improving your intuition. Once you do, you’ll find that you can categorize most problems based on Algorithms — The Major Five topics are:-

  1. Ad hoc/ Implementation Problems
  2. Programming Paradigm(Greedy, backtracking, branch and bound, DP, Divide and Conquer, Brute force etc.)
  3. Graph Theory(directed, undirected, weighted, rooted(IN & OUT) and unrooted tree, DAG etc.)
  4. Math(Number theory, Computational Geometry, Combinatorics, Linear Algebra etc.)
  5. Others(String Processing, Bit Manipulation etc.)

Every problem you’ll see will be a version of these. So make sure you know enough of each to attempt a new problem of that type, otherwise you’ll be going in blind.

Follow the right people

Similar to every app or platform you use, following the right people will be of paramount importance to give you the best content. Same with leetcode , except it’s not built that way. You can’t seem to navigate the platform to get user specific posts beyond some recency. If you’ve been going through discussions for a while, you’ll definitely admire some coders who post clever solutions to different problems on the discussions tab. You might even want to emulate or adopt their style and learn from it. Here’s a simple google search trick to get all the posts made by a specific leetcode user.

site:leetcode.com inurl:discuss inurl:problems intext:stefanpochmann python

Search for posts by the specific person. Here are some of my favorites and go-to’s when I was learning

site:https://leetcode.com/ "StefanPochmann"
site:https://leetcode.com/ "lee215"
site:https://leetcode.com/ "Awice"
site:https://leetcode.com/ "zhijun_liao"
site:https://leetcode.com/ "fun4LeetCode"
site:https://leetcode.com/ "DBabichev"
site:https://leetcode.com/ "agave"
site:https://leetcode.com/ "yegao"

I’ve admired some of them for a while now, especially the first two in this list. I’ve definitely learnt a lot of cool tricks and different ways of thinking and I’m positive you will too, when you see what I’m talking about.

Build your Style and arsenal of tricks

This is an interesting concept in martial arts called SHUHARI. After following multiple solutions and discussions from multiple programmers, when attempting new problems , you are bound to develop your own unique style of problem solving.

SHU-HA-RI can be applied to anything

You might be using more of functional programming, inbuilt python tricks, or some algorithms you learnt in a different context once you get through the first 150. Vectorizing loops, using binary for strings, traversing graphs using complex numbers, using math and number theory to get to O(1) mare just some of the various examples of code improvement I have noticed.

If you enter into an interview and solve problems in your unique way, you’ll instantly stand out from the rest of the people who only look at it as a DSA problem and not as a work problem. Most people subconsciously do not identify such issues in their work code. They keep writing lines of bogus that doesn’t scale well because they never learnt how to think of a problem from different perspectives or even considered alternate approaches. A recursion problem is a recursion problem and a DP problem is a DP problem to them. They fail to see the overlaps and crossovers.

I have certainly learnt a lot from StefanPochmann and lee215 and several other programmers mentioned above. One of the most interesting pieces of code I adopted was using ‘Complex Numbers for Graph Traversals’.

If there is interest in expanding on this topic in the comments, I’ll write about it and some other tricks in a new blog post.

Make notes to review

Write down stuff. You might put your faith in your memory but that will fail you. How much of your undergrad coursework do you remember right now? Making notes will allow you to update information and be more disciplined. Keeping them safe digitally somewhere online like a Github repository would be best!

Don’t do the left, Do the right thing

You might come up with some ingenious solutions at times when you are driven by a spark of creativity or feeling the zone. Document it. All of this will also reflect in your work life and you’ll get better and write better code.

SOCIAL PROOF :

On the off chance that you need to interview you have a great system of notes and codes to refer to ! If you think I’m just preaching, here is some social proof . I had interview calls through the year while I was preparing (even from Deepmind in March). I continued the grind despite failed interviews, taking up a start up job for 6 months and doing more interviews towards the end of the year.

This was my grind during the last year of Grad school

I got job offers from Amazon, Google and some other start ups towards the end of 2018 and picked Walmart because it was the best fit for my career and personal goals at that time. You can look at my career trajectory on LinkedIn to see how that turned out !

2 promotions in 3 years, Not bad, eh?

Your efforts and the skills you build up, will never betray you. So assimilate everything you read in this blog and act on it this year, and you can be self assured that you won’t have any issues or worry about the “interview process” ever again.

Once there is some feedback, and I gain more insights to add, I’ll be sure to update this blog post. I hope after reading this, you’ll start looking at Leetcoding as a daily continuous habit to improve your skills and not simply as a tool for interview cramming. Till next time !

If you liked this blog and found it helpful, please share this with your network and hit that claps (👏) button below to update the recommendations. Feel free to add any insights you’d like to share, in the comments below! If you ever lose your way, come back and read this

InterviewNoodle Community

Programming
Coding
Leetcode
Interview
Computer Science
Recommended from ReadMedium