How to Improve Problem Solving Skills

How to Improve Problem Solving Skills

DSA

The ability to solve problems applies to more than just mathematics homework. Analytical thinking and problem-solving skills are a part of many jobs, ranging from accounting and computer programming to detective work and even creative occupations like art, acting, and writing.

This article is about how to improve your problem-solving skill in Data Structure And Algorithms. Solving a DSA question has always been considered an impossible task to do. You don't need to be a wizard to solve a given problem. You just need to know certain steps but you might not be solve the given problem on the first go. You will need a lot of practice to solve the problem consistently.

Step 1: Learn the One Programming Language.

For the DSA any one programming language you required. While learning a programming language you only learn the basic concept of that language. If you are a beginner then at least 1 month is enough for learning the language. Learn basic concepts such as Data type, Function, Switch statement and OOP.

Languages: C++, Java, Python, JavaScript, etc.

Resources for learning :

1 . W3school

2. GeeksforGeeks

Step 2: Learn Data Structure And Algorithm.

Data structure and Algorithms are a very important part of cracking good Companies' Interview round. By learning you can complete 60% of the problem. Only if you learn the DSA concepts clearly, you will be able to approach optimized and well-structured solutions.

DSA can be learned in many programming languages. Popular languages include Java, C++, Python and Javascript.

Resources :

GeeksforGeeks, Coursera

Step 3: Where to practice?

For practicing the DSA problem there are many platforms are available online.

Popular platforms for practicing DSA problems are Leetcode, Codechef, Codeforces CodeStudio, Hackerrank, and GFG.]

\>LeetCode and Codechef are the most popular platform for problem-solving. I prefer Leetcode for problem-solving practices in Java.

Step 4: Step to solve the problem.

1. Understand the question completely.

  • Look at the question and try to understand it completely. Make sure to run through the examples to verify that your understanding of the problem is correct. How to do that? The input should give the required output. You should be able to verify that.

2. Come up with a brute-force solution. Verify if it will pass.

  • When you start practicing DSA, it would most likely be an exponential or polynomial solution. With sufficient practice, your brute force solution would also be pretty optimal and close to the required solution.

    This is generally not the solution you are going to code.

    Steps:

    • Try to come up with a correct solution as soon as possible.

    • Dry run your solution on the sample test cases to verify if your solution is correct.

    • Verify if your solution is optimal based on the time and memory limits. Do this by computing the approx number of operations based on the constraints. If it will pass then this is the required solution.

    • Even if it is passing, give a minute to see if you can think of a more optimal solution.

3. Dry-run the optimal solution on the edge cases

  • Once you have an optimal solution that you are ready to code, make sure to dry-run your solution on the sample tests and the edge cases that you came up with earlier.

  • Before you write the code, you should have a correct, optimal solution ready which should pass on all the test cases. Writing code is just about converting logic to code that a computer can understand.

4. WA (Wrong Answer)

  • The most likely reason is missing edge cases. Think of more edge cases and test with the custom input. If the platform provides the failing cases then compare it with the output that your code gives on those test cases and try to debug.

  • Make sure that you are not printing anything apart from what is required.

  • Make sure that there are no extra/missing lines or spaces.

5. Optimize your code.

Now that you have approached to a brute-force solution, you still have room for improvement. Think of more optimized. At this stage you can get help of pen and paper. Sketch out the working of the input and output that can be arrived at using the given input. Try to get the pattern of working with different inputs.

6. Look for improvements.

If you can't arrive at the solution to the problem, you can take the help of youtube and other editorials. You take the same approach and algorithm that is used.

7. Submit your solution.

Step 5: Practice Daily .

I am also a beginner I started my DSA journey in sep-2022. Participate in the weekend contest. Solve daily at least 2 problems. Focus on the medium-level problem.

Did you find this article valuable?

Support Samir Atpadkar by becoming a sponsor. Any amount is appreciated!