DEV Community

ZhiHong Chua
ZhiHong Chua

Posted on

1 1

How I applied Leetcode lessons to work

Leetcode in itself isn't very useful. Yes, take 30 minutes to solve a Data Structures & Algorithm (DSA) question in an interview, but over the past 6 months in actual work, I've hardly had the need for DSA.

However, the mathematical thinking behind it may be very useful! Recently my feature's lead was ill, and I stepped up to fill that role. Swimming around in complexity and edge cases, and suddenly all those months of Leetcode practice just clicked!

1. Problem-Solving Skills

This is a process of a typical Leetcode interview

  1. R - Repeat the question to make sure you understood problem.
  2. E - give Examples to make even more sure.
  3. A - suggest Algorithm(s) that might work.
  4. C - Code it up, after permission from interviewer.
  5. T - Test your code, run a few test cases.
  6. O - Optimize the time / space complexity.

Credits: https://www.youtube.com/watch?v=DIR_rxusO8Q (omg, I viewed this prior to my first coding interview in May 2021)

And this is how I solved the problem at work

  1. R - Revise problem information and constraints
  2. E - think of Example test cases
  3. A - find Areas in the codebase where I could implement new feature effectively, consider maintainability etc.
  4. C - Code it up
  5. T - Test it (with an XCode Simulator)
  6. O - Optimize (in terms of writing Clean Code for maintainability. Time complexity is less important here in Frontend)

It is pretty much the same process!

2. It's OK to Simplify the Problem

Image description

Some days your mind is just sleeping, and in Leetcode you just can't solve. But you can solve a simpler sub-problem, rest, then come up with a better solution another time! (Though the interviewer might be like the GIF above)

Same goes for work, sometimes you can only deliver a partial feature (but your users won't know that) and that's OK! It can be built up slowly.

Just make sure to communicate the challenges and get everyone onboard.

3. Copy-Paste

Don't need to re-invent the wheel. If a problem you're trying to solve has been solved before, just copy-paste (but take care to check that code works / is safe).

4. DETERMINATION

Challenging problems are tough to crack, but with determination and focus, we will eventually get through it :)
(though Curiosity really helped me see it through also hmm)

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs