Oml? I thought you meant one million Leetcodes - Kyla Canares (2023)
DSX Checklist | Neetcode Roadmap | Neetcode Website | Leetcode Website
Why doing Leetcodes is worth it
As companies try to level the playing field for penultimate-year students who may not have even touched a statistics textbook yet, they need a more standardized way to measure aptitude.
This often comes in the form of general math, statistics, and probability questions, as well as programming skills and algorithmic thinking.
Here, we cover the latter.
ML Algorithms
Machine learning algorithms aim to most effectively exploit information in the data, and patterns, in order to yield the most accurate output.
Algorithms
Normal algorithms aim to most efficiently exploit information in the data. E.g Binary Search exploits the fact that the data is sorted. You can test this on any Leetcode; the optimal solution will always be the one that exploits the most information in the data.
This section emphasizes the importance of programming fluency and algorithmic thinking for data scientists, offering a break from ML’s probabilistic nature and strengthening core skills.
Practical Advice (for the average person)
- Remember that little ‘idea’. That little quantum of logic or information is what makes or break the entire question. If you have done 100 Leetcodes you should have memorized 100 key ‘ideas.’
Getting set up
- Watch this if you don’t understand time and space complexity.
- Practice with a memorizing mentality - ensure that you can actually remember this when it comes up in the interview. Also helps to redo the ones you did a few weeks ago.
- Don’t panic. At first, the number of things they can test you on seems unlimited, but as you cover more ground, you realize that it is actually quite limited.
- Watch tutorials. I know it’s boring, but watching other people code (and hear their thought process) can be one of the most effective ways to improve.
- Know to distinguish between your lack of algorithmic skill and lack of programming (obviously they are somewhat interconnected). But it’s like thinking you’re bad at creative writing because you don’t know French - you have all the ideas but
Little ways to stand out
- Check the constraints first (that section at the bottom). It’s so easy, and will make you look like you know what you’re doing.
- Voice your concern about edge cases, and be conscious of them while coding.
- Remember to practice everything performant; how you type, explain.
- Practice talking aloud through what the space and time complexity of your approach is.
- Practice the
Follow upsection
Never do Leetcodes in silence
- In your interview you will have to think, code, and speak at the same time, so it’s better to get used to it than do it for the first time in your interview.
- Speaking while you think engages a completely different part of your brain, which will feel uncomfortable at first, but it can ultimately be useful (and make you a better interviewee)
- Don’t fall into the habit of requiring complete, deep, silence to enter your thinking process, or work through logic in silence.
Puzzles, not code
- This shift in mindset will take you far.
- Almost all Leetcodes require some purely logical observation to be made first, which are completely independent to the way the code is written.
- Leetcodes are more puzzles than code to be written. If you get too caught up with the fact that you need to write code, you will probably struggle.
- Don’t get put off by ‘data structures’. Yes it’s computer science, but it’s not tricky at all, embrace the logic, and reap the rewards when you suddenly have more tools at your disposal to solve harder problems, with barely any input effort (they’re really not that hard).
Where’s your Leetcode notebook?
- If you don’t have one already, make one. You will immediately notice an improvement in how enjoyable Leetcodes become, as well as how quickly you crack them.
- Engaging your visual cortex helps, a lot. (For more rich mental embeddings)
- Writing out pseudocode should feel like doing math by pen and paper.
- In fact, Leetcodes should start on the page, not the computer.
Leetcodes can be addictive if you let them
- Don’t stress. Just enjoy the process of cracking the puzzle. If you can’t figure one out, don’t stress. Just walk away, think about it while you do the dishes or something.
- A tactic I love is reading a decently sized one in the morning
Redo the ones you did a few weeks ago.
- Leetcodes are a healthy balance of 1) exposure and 2) repetition.
- Yes everyone just wants to see that number tick up. But at some point the input/value curve slows down…
- You actually get much more from redo’ing leetcodes: you understand them more deeply, you can actually redo them, and better.
- At a certain point you get more out of repeating old ones than doing new ones.
- That said, increasing your breadth gives you better odds in the interview.
- If you struggled with one yesterdya, do it again first thing in the morning; show it who’s boss.
Don’t check the answers.
- If you can’t figure it out, the best thing you can do is give up. Walk away, let the question stew in your head while you move onto something else. Let it marinate - or sit and think about it, whatever suits your style.
- It’s not really about getting the answer right, as it is sitting there and thinking about the answer.
- Get comfy, play some calming classical music, and just enjoy the puzzle solving process, enjoy the brain teaser.
- Step away and do something else, clean your room while you occupy your mind with the problem, just in a change of scenes.
Check the answers.
- It’s okay to refer to sample solutions when you start out - it’s a great way to learn, but as your ego increases, you will resent checking them even more.
- If can’t figure it out, use the hints provided by Leetcode in the
Descriptionsection:

- If you really can’t figure it out, don’t go straight to the answers, instead, do this:
Me:
"Can you give me a hint for how to solve this (((WITHOUT GIVING AWAY THE ANSWER))): ... "
ChatGPT:
" ... "Improving.
- Again, redo them.
- A neat trick: Use the word ’roast’ - you will learn a lot from savage ChatGPT.
If you’re unsure about your algorithm: "Roast my code"
If you’re confident in your algorithm but unsure about your implementation: `“Roast my algorithm”
Try to be bilingual
- Be bilingual: be able to complete any Leetcode in more than one language. Implementation is really not that different - most of the time it’s only syntax you have to learn.
- If you haven’t already decided, C++ is a good first choice. You can learn it here.
- Knowing just one extra language immediately puts you ahead of the millions of people who already know Python
### ***Get good at stress testing your logic. Be explicit, and thus eliminate any room for error***
While your solution is already optimal in terms of algorithmic complexity, there are minor optimizations that can be made: