Leetcode 101
Leetcode is a platform to practice coding interview questions. If you’ve never done leetcode before, I highly recommend starting with the Explore section, specifically the Beginner’s guide or the Data Structures and Algorithms guide. Specifically focus on all the easy questions first and use them to build practice.
Prepping for Leetcode
If the easy Leetcode questions seem daunting to you, then I highly recommend reviewing your CSC148 or 110/111 material. You will need to first learn the basic data structures and have confidence in solving the course questions before you can solve any Leetcode questions. Once you have practiced the course content, I recommend reading this Hackernoon article detailing the most common coding question patterns. If you’re a first-year, don’t be alarmed that you don’t know the patterns after the ninth one. You will learn this in your second-year data structures class, specifically CSC236 and CSC263. There are also various YouTube videos explaining this if you need a refresher.
💡External resource link:
- Google has a Dev Tech Guide with a Data Structures and Algorithms course. The course has videos, questions and quizzes.
- FreeCodeCamp has a Algorithms and Data Structures and the same course in Java
- W3 School’s Introduction to Data Structures and Algorithms
Leetcode Planning
Once you’ve done all the prep work and learnt everything needed to start Leetcoding, you can plan out your Leetcode practice. Leetcode is very overwhelming and without an effective plan, it is hard to stay motivated. Leetcode is one of the most draining tasks in the job search process. It is not something you can complete like behavioural interview preparation. It is a process you will be repeating every job search season.
When you’ve never done Leetcode before, seeing over 500+ questions on Leetcode can be daunting. Furthermore, if you’re a first/second year, I highly recommend focusing only on easy questions and starting with the Leetcode Explore guides. Once you are comfortable with that, you can start the Blind 75 list. This list features 75 questions that cover all the common data structures and algorithms you need to know. If you need some support to solve the list, you can use Neetcode’s YouTube videos on Neetcode.io.
If you’re a third/fourth-year or have been through the Leetcode practice once, I highly encourage redoing the Blind 75 list again and then tackling either the NeetCode 150 or do 2 medium problems every practice session to improve your Leetcode ability. Another option is doing company-tagged questions on Leetcode.
Once you’ve chosen a Leetcode practice list, you can use some sort of tracking system to track your progress. This could be Leetcode/Neetcode’s website or an Excel or Notion database. You can also take this one step further and track your confidence levels to see how you improve each season. If you track your solutions, you can also track how much your code has been optimized.
Effective Leetcoding Practices
Practicing Leetcode on your own is not always reflective of the technical interview experience. In a technical interview, you need to explain your thought process and talk out loud as you code. This can be hard at first as we tend to code in silence by ourselves. So practicing thinking out loud when you leetcode can ensure you feel more comfortable doing the same in an interview.
When you first read a question, try to stop reading the question before the constraints section and see if you can come up with questions related to the constraints. Next, try brainstorming the problem out loud and writing out your solution as pseudocode or comments. Once you’ve written out your solution, assess it once for validity and then code out the solution using your pseudocode/comments. Try to keep talking out as you code. After coding, trace through the code with one of the Leetcode examples and then calculate the space and time complexity. Lastly, run the code.
If it runs successfully, you can focus on optimizing your code. If your code is optimized, then you can move on to the next problem. If it doesn’t run successfully, you can continue in the interview setting and think of how you would fix it. Again keep trying to think out loud. If you cannot solve it by yourself, watch a solution video and mark the question in your tracking system. Wait a couple of days and revisit the problem again. If you can solve it this time, you can take the mark off. If you cannot solve it again, I recommend revisiting the concept the problem is based on and then revisiting the problem again in a couple of days until you can get it right.
Post-interview leetcode
Once you start solving OAs and technical interviews, you will start recognizing the data structures and algorithms you struggle with. Make a list of these and try to do more Leetcode problems in these areas. Furthermore, just because you have interviews, unfortunately, it does not mean you can stop Leetcoding. You will still need to continue your Leetcode practice until you have an offer.
If you’re tracking your Leetcode practice, I highly recommend marking the questions you see in interviews/OAs or at least ones similar to them and at the very least the data structure/algorithm asked. This data is extremely useful in tailoring your practice sessions and future job cycle preps.