My Leetcode strategy

New iomanip
Oct 17 28 Comments

I wanted to give back to this community after I've been lurking for a while. I want to share some Leetcode tips since I'd say my strategy differs from most that are posted here or elsewhere. My account will probably be deleted soon since I've used a non company email to sign up (I don't have a company email yet), so don't expect answers after a certain time.

New grad (MS). I got an offer from Microsoft (TC 180k in Canada) and Google (L4, in team match stage). First time interviewing.

Fundamentals: I have a pretty good knowledge of fundamentals. If you don't, I 100% recommend you go through an algorithms book. Yes, I know, it's no fun if you haven't done a class on it before, but I believe is the best way to at least get a grasp of everything. I dislike interview preparation books (CTCI is just bad in my opinion), but I guess they're better than nothing. I suggest CLRS as a first algorithms book. You don't need to understand the math behind it, but at least be comfortable in how to design an algorithm.

Leetcode: I first did the "Top Interview Questions" collection (available for free), I did the medium collection fully and some of the problems from the hard collection. It's good because it exposes you to a lot of different areas (you need to be good at ALL of those).

Then I bought Leetcode Premium. This unlocks company tags (useless for some companies like Google, more useful for Microsoft and others). I spent 90% of my time doing the "mock interviews". Trust me, that was the thing that really made me excel in my interviews. The mock interviews give you a strict time limit, and in the end, they give you a percentage rating against all the other people that did the same mock interview set. This is much, much more useful than looking at the percentile for individual problems since many people just copy and paste the code from the top most-voted answer and get 100% percentile, making the average score go up. In a mock interview you don't have access to the discussion forum (of course, you can open another tab and cheat, but I feel like most people won't do that).

Be really comfortable with easy questions. This means <5 minutes each, at most. Binary search, sorting, simple data structure operations must be automatic. Medium questions are the most important ones to do in order to prepare for interviews. Don't spend too much time on hard questions: if you are comfortable with mediums, then usually hard questions are just a intricate mix of medium questions. If you can't get to a solution after 30 mins (or 1 hour if you feel like you're close), just look up the solution, and then go back and solve the question in your own code. Don't copy and paste!

Once you're comfortable solving questions, focus on speed. Mock interviews are good for that, because they give you a time limit and put you under pressure. My target times were:
Easy: < 5 minutes.
Medium: < 15 - 20 minutes.
Hard: < 30 - 40 minutes.

I achieved the desired target time for easy and medium questions, but hard questions can be really frustrating and never achieved a consistent < 40 minutes. Some hard questions I was never able to solve, and that's fine. Focus on medium.

My ratio was 20/70/10 easy/medium/hard. I had one month to prepare, I did around 200 leetcode I would say (unfortunately problems solved in mock interviews are not counted towards the total solved, so I'll never know how many I've actually solved).

Then, identify one area where you suck. In my case, dynamic programming. Read up tutorials / book chapters / explanations on that area, and understand the solution to common problems really well (like rod cutting for dynamic programming). Then go to the relative section on Leetcode and start doing them until you feel good. After doing like 15 dynamic programming questions I finally felt like I could get the hang of it.

In terms of tutorials: do not use random online resources! I can't stress this enough. There's so much crap online that you don't want to get inspiration from! GeeksForGeeks is a terrible resource, for example. Answers are often wrong, with bad English, terrible explanations, and the site has a horrible interface. Prefer blog posts from reputable sources (like actual interviewers), or books. Just search your problem on Google and choose wisely (look at multiple explanations!).

I hope this helps!

TL;DR: Leetcode mock interviews saved my life. Use real resources, not random online blogs. Focus on correctness, and then speed.

comments

Want to comment? LOG IN or SIGN UP
TOP 28 Comments
  • Roku cruella
    Bless your heart for taking so much time and effort to post this.

    Good job.

    And more importantly congratulations ๐Ÿฅณ
    Oct 17 0
  • Qualcomm / Eng Bangalore_
    Congratulations!! Dont you find the algorithm book clrs to be too much to do. I.e its lot of theory. Did u focus of specific ones ?
    Oct 17 1
    • New iomanip
      OP
      It does have a lot of theory but you can just skip the math heavy parts. I'd recommend just go over the basic chapters that detail Big O complexity, sorting, and common data structures (arrays, linked lists, hash tables, trees and graphs).

      Then venture into specific topics such as dynamic programming or advanced sorting algorithms. Many do not know, but the book has a very simple and slick algorithm for the median of two sorted arrays that is way easier to reason about than most code you find online.
      Oct 17
  • New / Eng vVJn80
    I would suggest "Algorithm Design Manual" by Skiena for interview prep over CLRS. Using CLRS to prep for interviews is the equivalent of reading a dictionary to learn English. CLRS is really a reference textbook for undergrad algo courses, using it for interview prep is severe overkill.
    Oct 17 1
    • New iomanip
      OP
      It is overkill if you have 1-2 months to prepare. If you prepare 6 months in advance, you may as well read an algorithms book. I mean, it's actually useful in real life.

      I agree that Algorithm Design Manual is a good book.
      Oct 18
  • Google JTCP86
    Amazing post
    Oct 17 0
  • FormFactor Tove1
    Dude what is CLRS?? And what is the different between that book and CTCI? I was thinking to buy CTCI but now that you said that I am not sure
    Oct 17 4
    • New / Data Stormy โ›ˆ
      Introduction to Algorithms
      Oct 17
    • FormFactor Tove1
      Is that the name of the book?
      Oct 17
    • New / Data Stormy โ›ˆ
      Yeah if you search clrs it should come up
      Oct 17
    • FormFactor Tove1
      Thanks!
      Oct 17
  • Amazon BlackOrca
    How r u getting 180k at Microsoft Canada? Whatโ€™s the breakdown and level?

    Nice work!!!
    Oct 17 2
    • New iomanip
      OP
      60, 100 + 40 + 40
      Oct 18
    • Can you explain those numbers please? And is this Vancouver?
      Oct 18
  • Apple Tim_C
    What about EPI would you recommend it?
    Oct 17 1
    • New iomanip
      OP
      In my opinion EPI is better than CTCI but aimed at someone with some background.

      But as with all things, it's a matter of preference. If you feel like CTCI helps you, go for it.
      Oct 18
  • Thanks a lot for this amazing post ! Can I DM you ? I need some guidance
    Oct 17 1
    • New iomanip
      OP
      Sure, can't guarantee that this account will be valid for a long time though.
      Oct 17
  • Microsoft carrots21
    This is amazing! Thanks for the advice! :)

    Mind me asking how many YOE you have? Did you also happen to study for system design?
    Oct 17 1
    • New iomanip
      OP
      < 1 YOE (just some internships).

      I did spend a couple of days on system design (I read some of the free content of Grokking the system design), but didn't focus on it because I was told there would be only coding interviews. Definitely not enough if you know they'll focus on system design though.
      Oct 17
  • Cerner / Eng Zenobia
    Did you have to do systems design? What did you refer for it?
    Oct 18 1
    • New iomanip
      OP
      As I've already mentioned, I didn't do system design.
      Oct 18
  • Mphasis / Eng ITzQ40
    One of the useful posts! Thank you and congratulations!
    Oct 17 0
  • eBay weaTgqXz
    ๐Ÿฟ
    Oct 17 0
  • Cisco algxde1
    Does bitwise operations matter?
    Oct 27 3
    • Qualcomm / Eng Bangalore_
      Mostly for system level positions
      Oct 27
    • Cisco algxde1
      Not for general SWE? Let's say for Google L3 SWE?
      Oct 27
    • Qualcomm / Eng Bangalore_
      Not really. But some of them may. Less likely
      Oct 27

Salary
Comparison

    Real time salary information from verified employees