Solving Coding Problems: 7 Steps On How To Do It

if you are finding it difficult to solve problems when writing code as a programmer (especially for beginners) even the simplest problems. This could be a very daunting and frustrating stage to a programmer. I honestly think it is a true test for amateur programmers to know if computer programming is really for them. if you have faced this problem at any point while writing code, don’t worry you are in good company. Over the years of much reading and tries and fails, I found the best approach to tackle a problem and come up with the most efficient solution for the problem.

  1. Understand The Problem

    There is no way you can solve a problem if you don’t understand it in the first place read out the question out loud   and pay very close attention to the question to get a grasp of what it really means and to look out for clues in the questions

  2. Leave Your Comfort Zone

    When I say comfort zone am talking about your computer, get a white board and marker even a notebook and a pencil will do to help you really understand what to are putting down because IDE’s already has syntax and libraries already embedded in the software for you and also, writing on a whiteboard might be required for your next coding interview so it is wise to get comfortable with it now.

  3. Brainstorm Solutions and Analyse Its Run Time

    Take a minute to think of solution out loud to yourself, use examples to find out what works and what doesn’t, find out what the runtime of your solution is and when you do ask yourself if this is the fastest runtime that can solve this problem.For example, if you have a code that solves a problem in O(n^2) and thesre is another solution that solves that same problem in O(n) that you didn’t know about or use, then your solution is not efficient enough. Plus it can also help you a lot while intervieing for a job.

  4. Debug your Code

    When you finally choose the best solution with at least runtime, write it out on the board and debug your code. look at the code carefully and look out for potential bugs that might stop the code from running things like misspelled names, missing semi-colons and open parentheses. Walk through your code carefully. Those things can crash you program so look out for them.

  5. Run Your Code on A Computer

    Now to type it into your computer and see if it works. if you followed the first 4 steps in this article there is a 90 percent chance your code is going to work.

  6. Practice

    In other to be good at anything you need practice no one became a good at programming overnight, it takes time and practice to be considered a good programmer. there are a lot of code problems online like:

    HackerRank
    Codeforces
    Euler
    Sphere Online Judge.
    They all have contests you can participate in to improve your problem-solving skills.

  7. Look for Solutions Online

    Yes you can surf the internet to find people that solved the same question already but that should be your last option and don’t make it a habit of looking for answer online before actually attempting to solve the problem yourself the whole purpose of trying it yourself is to develop your problem-solving skills, and if you find an answer dont just copy and paste make sure you understand what  you are copiying, try to understand how he or she solved the problem.

Leave a Reply

Your email address will not be published.