Here’s what I learned after 30 Days of LeetCode

Timmy Ajibode
6 min readJul 5, 2021

--

Prologue

They say it takes 18 to 24 days to pick up a habit and an average of 66 days for a person to pick up a new behavior. Well, I am not trying to become divisive, but it is clear that whoever came up with that statement has never tried programming.

For readers that are unfamiliar, Leetcode is a website where you can practice your coding skills. It provides questions that require algorithms ranging from easy, to medium to difficult. The big 5 companies alternatively referred to as FAANG(Facebook, Amazon, Apple, Netflix, and Google) use this platform to weed out prospective software engineers. The use of such a platform can then be easily understood to this end(I mean who would not want to work for any of them..rightt.??). This platform has led startups and other tech companies to employ a similar interview approach to get top-level software graduates.

The technical process this involves is to give the interviewee a question randomly picked from the company’s Leetcode questions database. This question must then be analysed, explained, and given a solution which the interviewer then assesses based on their respective criteria. The thinking here is to know as many questions or understand as many algorithms as possible so the probability of not knowing the provided question on the interview day is very slim.

My approach here was to split the questions into the 3 categories and solve a question each night before bed. I divided the 30 days into 10 days of easy questions, 10 days of medium difficulty, and 10 days of hard difficulty.

THE EASY

The easy questions initially took me by surprise. I was brought before the humble court of “nahhh…your code is bang average if that”. The platform provides this concept that analyses your code and tells you how good it is, if it could have been written in a better way, and the time complexity. One of my first questions was to add 2 numbers in an array when you are given indexes only. I wrote my code providing a solution that I thought would be sufficient and the development environment gave me a low mark based on the previously mentioned benchmarks.

At this point I realised, this might not be the best challenge for this month. I recall wanting to change this challenge/task for this month but I realised I would be cheating myself if I didn't go through with it. The next few days of this difficulty started to pick up and I started realising the editor liked when language features are used in conjunction with the algorithm itself .e.g If the tasks involved search and replace for a given array. The benchmark will rate a solution that would just use a replace function that comes with most languages rather than writing a loop that will go through the given array and also contain an if statement which will do the replacement if the number been searched for is equal to the number that the loop is on(That was long-winded but you get the point).

Towards the end of the first 10 days, I felt my confidence building and I had my approach for the proceeding 10 days of medium difficulty penned down.

THE MEHHHH(MEDIUM)

I knew this level could be like the lottery. The reason for this thinking was programmers had a varying level of technicality and what could be easy for me could be very hard for others and vice versa. This was one of my fairly enjoyable levels. This was because I cheated slightly. I realised quickly that this level was similar to the few university algorithms I came across when I was learning python e.g Binary Search Algorithms, Sort Algorithms, Trees, Linked List, etc. I refreshed my memory with these algorithms before I approached these questions. These made the questions slightly easier with respect to logic only. My solutions started to turn once again to is it working? if it is, submit it. I claimed success by a hair’s breadth as solving a medium question was a feat of some sort.

As I progressed in this category, edge cases started to become a bit more of a problem. There are test cases for every question a user has been given. The user algorithm gets ran against these cases and gets graded. Consider an edge case as a construct contained within all the possible solutions that an algorithm must pass to be sufficient.

At this point, I then started to understand the main aim of the platform. It was to allow the users to write algorithms in the shortest yet so powerful way that would be sufficient and efficient when used. Questions in this category included Ugly numbers, Odd and Even Linked List, Binary Search Tree, etc.

THE THERE’S NO POINT TRYING(THE HARD)

This level is a humbling level. It is made to be extremely difficult and turn a lot of people away, at least it was the way it felt. I then realised that,if I was to continue on the path of 10 hard questions before bed, I should be ready to go to work like a zombie. I rehashed a strategy which was 2 hard questions for 10 days and also to be selective with the questions.

One of which is a Sudoku Solver. It felt familiar as I had written a recursive Sudoku solver before. However, the difference was this was a 3 by 3 self-contained Sudoku Solver. This means it was a Sudoku solver that had 9 cells of Sudoku side by side(3 on 3 levels). I initially tried embedding my previous solution but it would only pass 1 of the test case as it was a single sudoku cell solver.

This was my brain on several nights during this level.

I then tried expanding the solver to account for the 9 cells but it proved too difficult. I then reverted to checking online materials, which helped majorly. I followed a material that attempted this question and then I came to a conclusion that I could not have possibly solved this question on my own as this requires complete mastery of data structures and algorithms. Whilst, I understood that this is a skill that I can get, it is not one that I can master in 30 days.

CONCLUSION

The platform is extremely good. It really helps algorithmic skills which can be useful when approaching problems and thinking like a programmer. It is a bible of some sort that some “tech heads” use to measure how good one’s programming skills are. I disagree as this is subjective and dependent on many factors. I would only use this platform to practice for new jobs, brush up on some programming skills, or particularly staying fit in coding terms. If any of those examples apply to you, I would structure out a plan on topics and do it well ahead of time.

Also note that there are other platforms that might be more suited to your style/technique or programming so some slight research will need to be carried out to tailor your programming needs.

Whilst none of these of the interests mentioned in the previous paragraph apply to me, I will probably be looking for other ones. Nonetheless, I enjoyed the whole 30 days of this process. It was tasking, fun, and eye-opening. It also echoed the words of my professor during my early years of university, which was that “Someone’s algorithm will always be more optimised than yours as no man is an island”. I also learned to once again live with my victories and failed test cases :).

Thanks for taking the time to read this article. Hope you enjoyed it.

--

--