The Leetcode Grind

As pretty much everyone who’s written a line of code in the last five years knows, the keys to passing a technical interview are the candidate’s ability to solve algorithmic brain teasers as efficiently as possible, and to explain their thought process as they do so. With software job postings frequently attracting over a thousand applications, this is the admittedly imperfect method by which companies separate the skilled wheat from the underperforming chaff. 

Put simply: to get a good job you need to dedicate hundreds of hours to practicing a skill with very little direct translation to the position to which you’ve applied.

“But how can I practice such a niche skill” you ask? Where computer science students’ fanciful dreams of $300k per year unicorn jobs go to die.

It is also where I’ve spent the last five weeks.

You don’t want to know how many submissions it takes to get to that second shade of green.

Most every CS student, during brief but magical moments when they’re not paralyzed by Imposter Syndrome, thinks that they’re an above average coder who can sail through data structure and algorithm problems. Much like how the average motorist thinks that they’re an above average driver, many are very, very wrong. To continue the analogy, Leetcode’s “Submit” button, being the ultimate arbiter of correctness, frequently acts as a traffic cop who would very much like to know why you were driving the wrong way down the freeway.

Because I knew my skill level there would only be sufficient to pass an interview for a lower tier position, and because in mid-December I can finally apply to the two FAANG companies for which I have referrals, in mid-September I decided to devote myself to honing my Leetcode skills. I had eight to ten hours per day of free time, and I opted to use the majority of it to ensure that, come December, I could at least stand a chance of passing an assessment from an elite company.

Obviously the remainder of my time was spent on my Kali VM, because learning doesn’t always have to be a grind.

I’m not gonna lie. My first week was rough. I decided that, to start, I would aim for ten problems per day. Eight ranked as Easy difficulty, and two rated Medium. That first week, the eight easy problems took five or six hours to complete. Each of the mediums required roughly 90 minutes. I couldn’t see the patterns involved in these questions, nor could I write good test cases to verify the accuracy of my solutions. The way Leetcode’s membership tiers are arranged, I couldn’t even debug my code to see where it was failing (a problem I solved by copy/pasting my code into a now-2,000+ line practice .cpp file and using my debugger of choice).

It would have been easy to get discouraged, but having heard from countless posters on the cscareerquestions subreddit that repetition was the best way to get good in a hurry, I persisted. I’m glad I did, because the second week things started to get easier. My easies were now down to roughly 20 minutes, and the mediums only took an hour or so. I was spending far less time reading documentation, could write better test cases, and was beginning to see what situations called for what data structures. I still wasn’t particularly good at this, but there was definite improvement.

Another place where hope gets gut-punched.

Week three was when I finally started to become comfortable. My easy problems took under 15 minutes on average, and mediums were down to about 45. My time and space complexity scores (the two provided metrics) were improving. I barely touched documentation. I was using reverse iterators and double ended queues with minimal difficulty. I was now even solving some problems without my IDE’s debugger, since I could spot where the bugs were most likely to appear.

Weeks four and five are a bit of a blur. Easy problems almost never required more than 5-10 minutes to solve. Mediums averaged under 25, with the majority of the required time being spent actually writing code instead of planning a solution. I even began solving Hard problems, which would have been laughably implausible during the first three weeks.

When I started, I read a post from a senior engineer at a top company saying that their warm up was ten easy problems, followed by two mediums and a hard, all in an afternoon. At the time I thought they were lying. Today, while I might not yet be able to match them, I’m not terribly far off.

… But I’m still not there.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s