Monday, July 4, 2022
HomeTechnologyWhat I Learned Solving A Leetcode Problem A Day For 45 Straight...

What I Learned Solving A Leetcode Problem A Day For 45 Straight Days | by Joseph Maurer | Geek Culture


Joseph Maurer

Being an engineer there are so many problems that I have to solve every day that you get into the flow pretty easily. But at work you are mostly solving the same type of problems on a daily basis that you forget that there are other exciting types of problems out there that require you to think differently. A great starting place is Leetcode or any other daily coding puzzle website. Let’s go over how to get started and best practices!

Step one is to read the problem and understand the example solutions that they give you. Work through the examples on paper if you have to, break down each problem into a series of steps to work toward the solution. Start thinking about potential edge cases that aren’t considered that your design needs to take into account.

Step two is to write some abbreviated pseudo code. I tend to think about this step like the high-level whiteboard coding interview. Run through the algorithm you are going to use to solve the problem. Write down any data structures that you might need and contemplate the time and space complexity. This is the easiest step to fix, but when I get stuck this is the work I refer back to to help get me back on track.

Step three is to code your test cases. Now that you have a good idea of what you need to do, write some additional tests and write your test cases in code if you are coding outside of their editor. Leetcode won’t tell you what tests failed outside of the ones they give you (maybe they do if you have premium? Not sure tbh)

Pro tip: Code in your editor. Not in the browser.

Step four is to code and iterate on your design. Just because it passes all the tests doesn’t mean it’s perfect. Think of potential optimizations or ways to make your code more flexible.

Step five is to look at what other people did and see if there is anything you can learn from their approach to the problem. There are often multiple solutions so don’t be surprised if you see something slightly different.

Here’s the list of every Leetcode problem I solved
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments