Basic: General Procedure For Code Problems

My general general steps and main takeaways from solving all the leetcode problems.

General Steps:

  1. Observe: Manually walk through sample data. Detect the characteristics. This is the most important thing.
  2. Coding
  3. Examine: One normal cases. And one corner case.
  4. Improve: Can I do better, in terms of time or space complexity?
  5. Review: Have I seen anything similar? What are they connections and common pitfalls.
  6. Discussion: Do you feel comfortable to read and learn good solutions from others? It might be very tough. Or you just feel too proud of yourself to listen to others.

General Procedure For Code Problems
Image credits to link


  1. If you can’t estimate the complexity of your soltion, you don’t understand it well enough
  2. If you target in improving your daily skills, focus more on easy/medium leetcode problems.
  3. Sometimes we can simplify the tedious logic in an creative but non-intuitive way.
  4. If your code has too many trivial checks, you might do it in a wrong way. There shall be better approaches in most cases.
  5. You know the idea, how fast you can finish the coding? And Bug-free?

See more blog_posts.


Share It, If You Like It.

Leave a Reply

Your email address will not be published.