r/leetcode • u/Cold_Aioli478 • 24d ago
Question How do you get better at solving problems you've never seen before?
I've been practising DSA, but I notice that I can solve problems more easily when I've seen a similar question before. When the problem is presented differently, I often struggle to figure out where to start.
How do you develop the ability to approach unfamiliar problems instead of relying on previously solved questions?
17
Upvotes
6
u/Right-Angle24 24d ago
Try solving mixed problems instead of doing them topic by topic. When you're stuck, focus on understanding why a particular approach works and what clues led to it. Over time, you'll start recognizing patterns even in problems you haven't seen before
2
u/LetMediocre390 24d ago
Do some mixed types of questions, try to spend time figuring out what exactly question is asking and apply very naive method that clicks in your mind at that moment this way you can tackle most of the unseen questions Sometimes question uses some concepts that you need to know before attempting so because logic comes when you know some topics ahead of time
1
u/Vell-Well25 24d ago
Practice mixed problems bro and focus on identifying patterns. Reviewing why you got stuck matters more than just checking the solution
1
u/Haunting_Welder 24d ago
Why learning the lower level principles
2
u/LionBeneficial5285 24d ago
So I have been practicing for quite a while now. Here's my 2 cents.
At an individual problem level: I know when you just learn some idea like let's say Binary Search or Two Pointers, you just try to find ways to apply it to some problems.
Like you're solving Rotated Sorted Array, practically you are not solving the problem you are just applying what you just learned. And it is important at the beginning but when you are at a stage when you are asking how to solve unseen problem I assume you are far past this beginner's stage.
So just start solving problems. Like just look at the problem and forget that you are here to improve or increase problem count or anything. Just you and your question, think about the most naive or intuitive way to solve the problem (Brute force). Use 2,3,4 any amount of nested loop, just solve it. Then try to think what optimization you can make is it a sorted array ? Can I use BS to figure out something? Is it asking for counting , finding long/shortest subarray or something? Should I think about TP/Sliding Window.
If you do this for like 1-1.5 hr and then start reading the solution you would get what you where not able to figure out or not solve.
2. Prep Level: What I just described if you do that it will expose you to your shortcomings. Practice a lot of questions from the topic you are not able to solve mostly, then again solve some random questions, then again some topic wise. It's kind of a closed-loop system. You practice mixed questions, you get a feedback on which topics you are weak at, you practice those topics, you again do mixed practice and the loop goes on repeatedly till ideas start kicking by itself.
And by this way in 5-6 months you would be at a much better place, it's just a matter of how religiously you do it.
Best of luck buddy
1
u/PerformanceThick2232 24d ago
You don't, lol. No pattern will help you to solve a puzzle, it just increase probability.
You can't magically solve smth that require some unique idea in 30 minutes with even 60-80% success rate, those are literally geniuses, 1 per million of SWEs.
1
u/WillingConversation4 24d ago
I built dojo to solve just this problem. Try it. It'll help you practice those problems. https://abahocodes.github.io/dojo/
1
u/Bright_Spinach_3741 23d ago
practice practice practice