16

How do I build up intuition for solving DSA problems?

Profile picture
Mid-Level Software Engineer at Grab4 months ago

Currently, I am only going through Neetcode's roadmap. I have solved 40+ problems.

My process is:

  1. Understand problem
  2. Try to solve the problem
  3. Try for 10 mins
  4. If not, go see the solution video
  5. Understand the solution and code up the solution
  6. Take notes in an excel sheet for revising later

I only read up theory related to the video in case its something I do not know about from before. Only for max 30 mins, so that I do not waste a lot of time reading up. My primary aim is to learn by solving problems.

I am able to solve some problems but I feel I still do not have the intuition for solving new problems.

My questions:

  1. Should I be reading up on more theory before I start doing more of the roadmap? Maybe go through Neetcode's courses.
  2. Does it simply take solving more problems to build up the intuition?
  3. Should I try harder on my own before checking the solution video?
  4. How did you build the intuition to solving new problems?
635
6

Discussion

(6 comments)
  • 15
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero
    4 months ago

    I'm going to make a LeetCode course relatively soon, but in the meantime, I recommend this: Effectively Learning Data Structures And Algorithms (DSA) For Software Engineer Interviews

    For your process, I recommend being stuck on Step #3 for longer (15, maybe 30 minutes). Step 4 is where I think you can improve a lot as you shouldn't just get the entire solution. What you should do instead is open just part of the solution and push your brain to fill in the rest of the blanks. This is harder with video, which is why I think NeetCode is sort of overrated honestly. The LeetCode text answers are far better at being modular.

  • 5
    Profile picture
    Eng @ Taro
    4 months ago

    Should I be reading up on more theory before I start doing more of the roadmap? Maybe go through Neetcode's courses.

    I wouldn't go through the theory first, unless the problem is completely unfamiliar to you. There are a few reasons why. it can be very easy to procrastinate because you get a false sense of accomplishment by just reading theory. Before you read the theory, I would try to struggle with a problem first. So, when you do read the theory, there will be more "aha" moments because you've found a more effective way to solve a problem compared to solutions that you thought of before.

    Does it simply take solving more problems to build up the intuition?

    To understand problems at a deeper level, it helps to connect different problems you've seen before with each other. It can be easy to fall into a trap of just memorizing solutions. I would try to go one step further to break down solutions into smaller chunks or patterns and connect the smaller chunks with smaller chunks you've seen in other solutions.

    Should I try harder on my own before checking the solution video?

    Yes, it might be worth it to operationalize what it means to try harder. You don't want to just stare at the problem for 20 extra minutes and hope that a solution suddenly appears out of the ether. I would try to write out, in pseudocode, 5 potential solutions that you could use to solve the problem. It doesn't have to be exact, but you want to have written down something. After you look at the actual solution, you can retrospect back on why each of your 5 potential solutions did/didn't work.

    How did you build the intuition to solving new problems?

    A lot of it is pattern matching. There are common components that make up a lot of solutions. If you can bucket a problem into a pattern, it can make a problem a lot more manageable. But, I will say that there are problems that are just completely out of left field. Sometimes you just get a tough draw. The best you can do is to communicate to the interviewer how you think about the problem, potential solutions, and why you think a potential solution is the best way to solve a certain problem.

  • 4
    Profile picture
    Mid-Level Software Engineer [SDE 2] at Amazon
    4 months ago

    Hi, I totally agreed with what Alex and Charlie mentioned above. Some of my thinking:

    • Practice makes perfect. By doing more problems, you will develop your own intuition. But you have to understand that acquiring knowledge will take time. Be patient, discipline and consistent.
    • Leetcode is my recommended platform. You can try all sort of solutions to solve problem. The key part is learning from other solutions in discussion to pick ideas which may inspire you solve future problems.
    • Take notes of everything you learn(Leetcode has note feature if you know it) so you can revise later.

    P/s: I worked At Grab before :)

  • 2
    Profile picture
    Mid-Level Software Engineer [OP]
    Grab
    4 months ago

    Thanks for your answers Alex and Charlie. I will try to incorporate this feedback. I realise I am memorising solutions rather than trying to understand them at a deeper level.

    • 0
      Profile picture
      Software Engineering Intern at Series A
      4 months ago

      hey OP, I see you are a mid level engineer. Is there any particular reason you are restarting DSA? I am a fresh grad and I have stopped pursuing DSA thinking it's too late lol. I am at a company where I am happy and my plan is to only apply to companies in the future that do not ask DSA. Alex has also said multiple times that Leetcode is not a very good use of time if you want to become a better SWE.

      Just wanted to get your insights to see if I might wanna reconsider my decision :)

    • 2
      Profile picture
      Tech Lead @ Robinhood, Meta, Course Hero
      4 months ago

      LeetCode in isolation doesn't make you a better SWE (as it's not true software engineering), but the tension is that a lot of the best companies (namely FAANG) require it to get in 😭. So LeetCode is often 1 step back (no growth, huge time spent) for 2 theoretical steps forward (getting into FAANG, which is generally great for career growth, especially new-grads).

      The big thing that's changed recently though is the market - It is so, so bad for junior engineers in particular to break into FAANG right now. For those engineers, they definitely don't want to spend hundreds of hours only grinding LeetCode as it will likely not matter. That being said, if you are able to get a Google phone screen or something, you should definitely break out the LeetCode.

      OP's situation is different as they have some experience already (seeing as they're mid-level), and they work at Grab, a company that's on the level of Big Tech (Grab has hired many great engineers from FAANG). So they are much better positioned to get Big Tech interviews compared to most SWEs, making LeetCode prep higher ROI.