# A Recipe for Problem Solving

In this blog, I'll show you problem-solving steps that are helpful during the interview process or when you face a tough challenge. Let's start!

*Step 1: Understand the problem*

Many people learn coding, but the biggest challenge is problem-solving. Anyone can learn syntax and write code by copying or following steps. However, problem-solving skills are crucial and come with practice.

Imagine you are in an interview and asked a question you've never seen before. Don't panic; understand the question first. Many start coding right away, but writing lots of code doesn't help. Instead, ask questions to clarify the problem. Helpful questions include:

Can we restate the problem in our own words?

What are the inputs for the problem?

What are the outputs of the problem?

Can the outputs be determined from the inputs? In other words, do we have enough information to solve this problem?

What should I label the important pieces of data that are part of the problem?

These question will help you to clear questions.

*Step 2: Examples*

Start with simple examples

Progress to more complex examples

Explore example with empty

Explore the example with invalid inputs

Explore if your code is able to perform this or not.

*Step 3: Break it down*

Write down the steps you need to take. They don't have to be valid code or follow syntax rules. Just outline the flowchart you plan to use. This will serve as a guide and help clarify your concepts. Essentially, create a layout, highlight the problems, and you'll be ready to go.

*Step 4: Solve or Simplify*

Solve the problem if you cannot ... **Simplify the problem.**

To simplify, follow these steps:

Find the core difficulty

Temporarily ignore that difficulty

Write a simplified solution

Then incorporate that difficulty.

Now, by doing this, we have already completed 90% of the challenge. If you reach this stage in the interview process, you can ask the interviewer for some suggestions. There's nothing wrong with this. If you solve 90% of a challenge, it demonstrates a lot about your problem-solving ability.

*Step 5: Look back and Refactor*

When it comes to interview, it's really important to ask these questions when you have finished solving the problem.

Can we check the result?

This one is obvious. We need to be sure that our code works.

Can we drive the result differently?

This is referring to the fact that there is rarely one solution to a problem

Can we understand it at a glance? Can we use the result or method for some other problem?

How easy is your solution to understand? Does it make sense when you see it on paper, a whiteboard, or in your code editor? When you write down a solution, take a moment to ask yourself if it resembles other solutions you have seen before. It develops a sense for solving other problems.

Can you improve the performance of your solution?

Here you need to be worry about time and space complexities. For example avoid a bunch of nested loops.

How other people solve this problem?

It can improve yourself, maybe even for the next interview.

These are the questions you should ask yourself.