Confused between solving coding problems and reading more solutions while preparing for interviews?

Programming Pathshala
2 min readDec 12, 2022

--

Hi, my name is Bharat Khanna and I am one of the Co-Founder here at Programming Pathshala.

This is a question that I get asked a lot at Programming Pathshala too. Or its other variations like — “How much time should I spend on a problem before reading its editorial?

During my preparation of coding interviews, I used to divide problem solving into following parts -

  1. Reading and understanding the problem — Let’s take an example problem. This problem looks very complicated by its statement. But, if you calmly try to understand it, you will get that it just wants you to look at all the query subarrays for different [l,r]. Those subarrays which have a positive sum should be taken in the answer and their sum is to be added to the total answer.
  2. Write a brute force solution to it. This would be a very basic solution to the problem. In this case, you would just loop on all queries, take the sum of the subarray for that query. If it is positive, add it to the answer.
  3. Optimise it using DSA. Here comes your ability to look for patterns which indicate using certain Data Structures and Algorithms. Like in this problem, because we are looking at subarray sums and recalculating it in each query, we can precompute it using prefix sum and answer each query in O(1).

You should analyse during your preparation the weak part.

  • If part 1 is weak, try to practice reading multiple questions and dry running your understanding on sample cases.
  • If part 2 is weak, do more easy problems on platforms to be able to at least think brute force for each and every problem.
  • If part 3 is weak, you need to work more algo by algo to make sure that you know and map different patterns to different algorithms.

To answer your question, ponder hard and try to at least reach till part 2 always. Then if you are unable to improve beyond a certain point in part 3, ask for hints if you have mentorship. If not, go for the editorial but note down the pattern you missed and make sure the pattern gets mapped for future :)

Hope you found it useful!

For more information, you can also login to www.programmingpathshala.com and take a free trial today.

Have a doubt? Reach out to us at info@programmingpathshala.com

--

--

Programming Pathshala

We are working to democratise access to Tech Education. We help students learn coding and be confident about themselves.