How To Understand, Break Down and Optimize Your Coding Problems.
Keep Things Simple With A Coding Checklist
INTRODUCTION
The biggest part of being a software engineer is the ability to solve problems effectively and efficiently. This is even more important than learning a programming language. When you understand the steps to take, and identify what to do, implementation is easy.
This is where data structures and algorithms come in. You absolutely do not need to memorize any code, syntax e.t.c. You just need to recognize patterns, know and understand techniques , be able to break your problem down effectively, solve and optimize. This is the biggest goal.
Previously, I wrote on how to think like a program. Be a better problem solver which you can read here. I also wrote on Problem solving approach for data structures and algorithms which you can also read here. They are all still valid but this weekend, I came across some new defined steps/checklist that I think is a game changer in breaking down your problems, solving, optimizing and most importantly, holding yourself accountable while solving coding problems.
Having a plan before diving in is important and this is also to me because I struggle with this as well ๐ข but sometimes, you just don't know how to break it down too (me too ๐) and here is to becoming better and more strategic programmers ๐ฅ๐. Creating a checklist with these questions and trying to follow through step by step will in no time help you become better in problem solving.
Now let's get into It !
When working on a problem, you should ask yourself these questions ;
Inspect
Did I explicitly state what the input was ?
Did I clarify what the desired output was ?
Did I construct a simple example that could be solved by hand ?
Did I write all Axioms ?
Did I write out and define all intelligent assumptions ?
Strategy
Did I brainstorm a simple solution ?
Did I analyze the runtime ?
Did I analyze the space requirement ?
Did I ask if the input problem set would be small enough for this to suffice ?
Was I able to come up with a better, more sophisticated solution ?
Did I analyze the time complexity of this solution ?
Did I analyze the space complexity of this solution ?
Did I compare it directly to my initial simple solution ?
Was I confident when I started coding ?
Did I think through all approaches that come to mind?
Did I explicitly write out my desired strategy ?
Did I explicitly consider base cases ?
How well did I handle getting stuck ?
Code
How cleanly was my code written ?
Did I explicitly check for any one-by-off errors ?
Was I able to predict what functions I will end up implementing ?
Did my brainstormed strategy solve the problem ?
How smooth was the coding process ?
Was I able to talk through my code ?
Did I leverage any interesting functions in my code ?
Review
Did I prove my runtime complexity ?
Did I prove my spacetime complexity ?
Did I write up different test cases and process them ?
Did I go line by line, no matter how trivial ?
Did I have to make any changes when reviewing my code ?
Resources
You know, I'm always on a lookout for new resources and yes, I did find some over the weekend.
Check out my main resource page here
Check out coding techniques and patterns here
Check out patterns to ace coding interviews here
Check out leetcode study guide here
Check out has table specific guide here
CONCLUSION
Now you have a list of questions to guide you in Understanding your problem, breaking it down ,solving and optimizing it.
Just as everything else, daily practice and being intentional helps a lot and will really help In this software journey. When you start out, it's difficult but at some point, it becomes second nature and you wouldn't even have to look at the steps at all anymore.
HAPPY CODING !!! ๐๐ฉ๐พโ๐ป