5. Solution Strategy
October 23, 2019 · View on GitHub
Practice
The more problems you solve, the better developer you will become.
However, to become good at solving problems, you will need 3P(practice, patience, and perseverance).
Read the problem
Whenever you start solving a new problem:
Read the problem at least 3 times. Try to understand the problem. If there is a note, read that. And then, try to think about the problem in your own words.
Input-Output
The second step is to think about possible input and possible output. If possible, think about 3 inputs and their output.
For example, if you think about the second largest number of a list...for the list below, 82 would be the answer.
[31, 15, 34, 87, 22, 82, 56]
Write the steps
If you see a large problem for the first time, write the solution steps in a paper...This will save your time while coding.
Incremental
While coding, use the print command to see the output. Most of the time, write a few lines, and then write a print command to see the output.
If you see the expected output, then delete the print command and go to the next step.
Comment
If you are solving a large problem, don’t forget to write a few useful comments...This will help you to debug.
Even if you have a solution, don’t consider it as the best solution. Instead, Google it. You will be surprised by seeing other people’s solution. You will learn a lot from other available solutions out there.
Keep doing
There is just one way to become good at problem-solving - Just solve more problems.
Take away
Keep solving more problems.
tags: programming-hero python python3 problem-solving programming coding-challenge interview learn-python python-tutorial programming-exercises programming-challenges programming-fundamentals programming-contest python-coding-challenges python-problem-solving
