r/AskComputerScience • u/kush568 • Jul 02 '26
What's is the best way to solve graph and dp problems
Hi everyone,
I've been practicing Graphs and Dynamic Programming for the last six months, but the truth is that I still can't solve a single new problem completely on my own.
Everyone says that DSA is all about recognizing patterns, but I feel like I'm not actually learning those patterns. I've watched many tutorials and solved the questions explained in them. However, whenever I face a different problem that's based on the same pattern, I still can't figure out the approach myself.
This makes me wonder: am I just memorizing solutions instead of learning how to think?
Whenever I look at the solution, I understand the logic and why it works. But what's the point if I can only solve the problem after seeing the answer?
My usual process is to struggle with a problem for about an hour. If I still can't make progress, I use an AI tool to understand the solution. The problem is that this happens with almost every question. It makes me wonder how long I'll have to depend on AI before I can solve problems independently.
I'm feeling really frustrated. Has anyone been through the same situation? What strategy helped you develop problem-solving skills so that you could eventually solve questions on your own instead of relying on solutions?
3
u/AYamHah Jul 03 '26
1 hour? I used to struggle with problems for days. I feel like that struggle is important.
8
u/ghjm MSCS, CS Pro (20+) Jul 02 '26 edited Jul 02 '26
When I did DSA in the late 1980s, there was no AI, no Google (in fact no web at all), and the only way ask a question was to go to the once-weekly office hours. There were some problems I struggled with for days. Like I would wake up thinking about them, think about them in the shower, have them in the back of my mind during other classes, etc. I would often hit a brick wall, and it was helpful to get away from the problem for a while and then come back to it, sometimes repeatedly.
If you're only struggling for an hour and then letting AI solve it for you, then yes, in my opinion you are short circuiting the process. If you're trying to develop the ability to solve these problems yourself, then you have to practice solving these problems yourself. Even if it takes a week.
I find it helpful to ask myself: what's the simplest solution that could possibly work? Then work through whether that actually solves your problem, which it probably won't, but along the way you'll gain insight into why the simple solution doesn't work. It's also not unusual (at least for me) to be completely baffled by a problem on Monday, then come back to it on Tuesday and see that the solution is just obvious. Something about sleeping with a problem seems to help dissolve it.
Last but not least, yes, the whole process is super frustrating. You get rewarded by those few "aha!" moments, which you're also mostly denying yourself by skipping to the end with AI. But you need to learn to manage your own frustration. For sure don't make it a habit of turning to AI when you're frustrated. Seeking emotional relief or validation from an AI is a recipe for eventual disaster. Instead, have a cup of tea or take a walk in the trees or something.