Tech IndustryOct 17, 2019
Newiomanip

My Leetcode strategy

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.

Add a comment
Roku cruella Oct 17, 2019

Bless your heart for taking so much time and effort to post this. Good job. And more importantly congratulations 🥳

Microsoft carrots21 Oct 17, 2019

This is amazing! Thanks for the advice! :) Mind me asking how many YOE you have? Did you also happen to study for system design?

New
iomanip OP Oct 17, 2019

< 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.

Google JTCP86 Oct 17, 2019

Amazing post

eBay weaTgqXz Oct 17, 2019

🍿

FormFactor Tove1 Oct 17, 2019

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

New
Stormy ⛈ Oct 17, 2019

Introduction to Algorithms

FormFactor Tove1 Oct 17, 2019

Is that the name of the book?

Mphasis ITzQ40 Oct 17, 2019

One of the useful posts! Thank you and congratulations!

New
GTFO_or_TC Oct 17, 2019

Thanks a lot for this amazing post ! Can I DM you ? I need some guidance

New
iomanip OP Oct 17, 2019

Sure, can't guarantee that this account will be valid for a long time though.

Qualcomm Bangalore_ Oct 17, 2019

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 ?

New
iomanip OP Oct 17, 2019

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.

New
vVJn80 Oct 17, 2019

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.

New
iomanip OP Oct 18, 2019

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.

Apple Tim_C Oct 17, 2019

What about EPI would you recommend it?

New
iomanip OP Oct 18, 2019

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.