Algorithms, Solving Problem Strategies

When solving an algorithm, I follow these strategies that were recommended by Colt Steele from his JavaScript Algorithms and Data Structures Masterclass on Udemy.

Step 1: Understand the Problem

  • Ask questions to understand the problem:

Can I restate the problem in my own words?

What are the inputs that go into the problem?

What are the outputs that should come from the solution to the problem?

Can the outputs be determined from the inputs? In other words, do I have enough information to solve the problem? (you may not be able to answer this question until you set about solving the problem. That’s worth considering the question at this early stage.)

How should I label the important pieces of data that are part of the problem?

Step 2: Explore Examples

  • Coming up with examples can help you understand the problem better

What steps to take to Explore Examples?

  1. Start with Simple Examples

Step 3: Break It Down

Explicitly write out the steps you need to take

This forces you to think about the code you’ll write before you write it, and helps you catch any lingering conceptual issues or misunderstandings before you dive in and have to worry about details (e.g. language syntax) as well.

Step 4: Solve the Problem

if you can’t solve it…SOLVE A SIMPLER PROBLEM!


  • Find the core difficulty in what you’re trying to do

Step 5: Refactor your code

Happy Coding!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store