Approaching algorithmic problems can be difficult, but it doesn't have to be.

It's just a problem that can be solved systematically!

The following steps should help you in your day-to-day work and in interviews.

🧵👇
1⃣ Get the requirements clear

Get all requirements clear first!

Only if you have no questions left, go on.

Ask as much as necessary!
2⃣ Implement the most basic solution

Start with a basic solution.

You don't need the most scalable solution right now.

Make. It. Work. First.

It doesn't matter if that solution is O(n^2) or even worse, it should just do what it is supposed to do first.
3⃣ If you can and haven't, yet, test!

Start testing.

Make sure that everything that should work, works as expected, and can be tested automatically from now on.
4⃣.1⃣ Substituting unit tests in interviews

When you're in an interview, and someone really demands a whiteboard coding session from you, define test cases on the whiteboard.
4⃣.2⃣ Substituting unit tests in interviews

Define them so you can go through them with certain input data, run through the algorithm in your head, and determine the solution based on that.

It's no unit testing framework, but it's a layer of protection for you.
5⃣ Think about improvements

Now as your solution runs, ask yourself if there is anything you can improve.

Can you make it more effective?

Is there a solution that can bring runtime down significantly?

Do you really NEED that improvement?
6⃣ Improve your solution

If you have an idea about how to improve your solution (and it is needed), implement it.

Your tests help you to ensure that your optimizations and improvements don't break your algorithm.

Improve something, test, improve something, etc, step by step.
7⃣ Find an end

You don't need to do this improvement thing forever.

Find the point at which you are out of ideas, or improvement doesn't make sense, anymore.

Just stop then, and let your solution be as it is.
8⃣ State what your solution is capable of

Clearly state what the solution you came up with is capable of.

If it has shortcomings, list them.
If it's good at something, list it.

Just be transparent, so that everyone knows what they deal with.
9⃣ Conclusion

If you follow all these steps, you'll have created something pretty solid.

It doesn't have to be the best piece of engineering ever, it is _one_ solution to _one_ problem, with advantages and drawbacks!
You can follow @oliverjumpertz.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: