Tags | problem solving skill/problem_solving |
As a coder, your job is to write code that solves problems. Problems that nobody has ever seen before! Problems that can’t be Googled or YouTubed! Problems where the answers don’t even exist on StackOverflow!
What you need is a strategy that will work on any problem. This might sound like something magical, but it exists.
Every problem can be broken down into smaller problems. And those problems can be broken down again and again. Eventually, you end up with a bunch of tidy little problems that can be written down as simple lines of code.
It sounds simple, but it’s something that takes quite a lot of practice.
Sometimes you get weird kinds of problems and you simply don’t know what the steps are. This is tricky. In these cases, it’s nice to rely on a pencil and paper. Because there is no school like the old school.
Try to do the problem by hand. Or perhaps a smaller version of the problem.
For example, if you are instructed to do something interesting to an array with length 1000, see what you can manually do to an array of length 5 that is equivalent. Try to solve it a few times with different inputs and see if you can find a pattern that you can break down :)
An edge case is kind of a funny thing to understand. You need to think of extreme values and see if your code can handle that.
For example:
This discussion thread has many more examples: https://www.quora.com/What-is-an-edge-case-when-programming
When writing tests for your code, it’s important to test all the inputs.
Less haste == More speed
.These wonderful articles explain this stuff well. Please read them:
The resources above are great resources for coding related problem-solving techniques. But, problem-solving is not unique only to coding. It is a skill to be practised in everyday life. Please check out the following content from MIT:
Of course, reading about code and watching other people code is great. But if you want to get good at this stuff: Practise practise practise.
Hackerrank is a great resource.