Dex Entry #002: Leetcode

As with any blog, it took me a while to figure out what I wanted to write about first. To me, this area is not just for sharing cool things I find, but also an opportunity to reminisce and learn from the things I have seen on my journey so far.
If there’s one thing that every CS student knows about, it’s the LeetCode grind! Personally, I’ve been chipping away at it for over 6+ years now (you can check my trainer card here), and I really cannot overstate just how much it has taught me about computer science!
It’s exactly like grinding levels in the tall grass~
When you first start, every “Two Sum” or “Reverse Linked List” feels like a Gym Leader battle. A Time Limit Exceeded (TLE) error is enough to completely wipe out your motivation, and sometimes all you can do is go back to earlier routes to train on easier problems. But truthfully, if you keep at it, you will eventually start knocking down problems one after the other by training yourself. The patterns and techniques I’ve learned through this process have been immensely helpful to me in my day-to-day tasks, way beyond the scope of just LeetCode.
Another really awesome thing is the fact that it doesn’t matter which programming language you use… any proper practice is good practice!
For example, my first 3 years were actually done using C++, but then I decided to switch to Python in 2023. Even though I was working with a completely new language, it only took me a little while to get back into the groove. Sometimes, I even end up using “non-Pythonic” approaches just because my underlying C++ brain finds the logic easier to comprehend :).
Of course, it goes without saying that you need to train properly; memorizing solutions is a trap.
Sure, you might be able to defeat the Elite Four by just spamming one over-leveled move, but in competitive battles (or technical interviews), you need to understand the environment and the situation.
What is important is the need to intuitively recognize the “types”, ie the algorithms and core patterns like Sliding Window, BFS, or Two Pointers, much more than rote memorization. Once you learn the type matchups, the problems stop being intimidating and start turning into fun sweeps that contribute to your exp gain.
Though it takes time, consistency definitely beats cramming. Doing one problem a day builds way more intuition than grinding 20 problems the night before an interview. Take frequent breaks, make sure to revisit old problems to test your memory, and remember: at the end of the day, no one else can train for you!
If you want to check out my GitHub history of LeetCode problems, click here.
The Ultimate Cheat Sheet to solving problems…?
def try_method(assumed_method):
work = attempt(assumed_method)
if not work:
return False
else:
return True
def solve_problem(problem_description):
solved = False
brain_energy = 100
# Keep trying until you exhaust your brain
while not solved and brain_energy > 0:
current_method = guess_pattern(problem_description)
solved = try_method(current_method)
if not solved:
brain_energy -= 10
print("It's not very effective... Trying a different angle.")
# If the brain is empty and it's still not working
if not solved:
print("Brain exhausted. Checking the discussion tab...")
look_at_solution(problem_description)
understand_logic()
take_short_break(minutes=15)
# Try to solve it by yourself again
print("Round 2: Let's see if I actually learned it.")
solved = try_method("What I just learned")
if not solved:
return "You have been wiped out! Time to retreat to the Pokémon Center. We try again tomorrow."
return "AC! (Accepted) XP gained!"