How to Solve a Coding Challenge

123jackcole

Jack Cole

Posted on November 22, 2020

How to Solve a Coding Challenge

Recently I've been doing LeetCode's weekly contests and I recommend anyone wanting to practice for interviews do them as well. The contests are great because they mimic the environment of a real interview. You are given a set amount of time (often 90 minutes) to solve several problems that increase in difficulty. The tests do a good job of imitating a high pressure environment rather than practicing problems in a lax setting.

After repeatedly taking these contests I feel that I've nailed down a method that works for me for solving problems and wanted to share. Anyway lets jump into how I solve each problem.

  1. Take the time to read the problem 2-3 times until I'm confident I understand it. If I have a few confusions I continue to the next step anyway which is...
  2. Examine the test cases and make sure I understand why the test inputs lead to the test outputs.
  3. If you're given the expected time complexity you can narrow down approaches they want you to use. For example, if they want you to do an O(log n) search you can first try a binary search.
  4. At this point I think about how I'm going to approach the problem while looking at the provided code as well as the provided constraints.
  5. Always try to think of edge cases that could cause problems before you code as well as while you are coding

Thanks for reading! I'd love to hear what works for you when you're solving a coding problem and how what you think I should do differently.

💖 💪 🙅 🚩
123jackcole
Jack Cole

Posted on November 22, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

How to Solve a Coding Challenge
beginners How to Solve a Coding Challenge

November 22, 2020

Learning Heaps in Javascript
beginners Learning Heaps in Javascript

September 12, 2020

Learning Tries in Javascript
beginners Learning Tries in Javascript

September 6, 2020

Learning Graphs Part 2: Traversal
beginners Learning Graphs Part 2: Traversal

August 23, 2020