I'm struggling to solve problems on leetcode

Im good at problem solving. I know how to code .I like to code ,but I want to solve easy problems on leetcode.im ready to give my efforts.suggest me overcome this

HI @Sanjaibaskar !

Welcome to the forum!

What previous DSA experience do you have?

Very little?
Maybe you have taken a DSA course? Or Two?

Or have you not studied DSA at all?

If you are new to DSA, then it is completely normal to struggle with Leetcode.

For the easy problems, if you know the underlying data structure or algorithm behind it or the underlining technique, then they will be easy to solve.
But if you don’t know, then you will probably try to brute force your way through it and have a few instances of timing out with certain test cases.

Let’s use Two Sum as an example
https://leetcode.com/problems/two-sum/description/

If you go with the brute force approach and try to compare every possible pair of numbers that adds up to the target, then you will end up with a O(n^2) time complexity.

But if you recognize that you can use a hash map, then the problem becomes easier to solve and has a better run time.

Same goes for the Best Time to Buy and Seel Stock problem here

https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/

If you don’t know the underlying technique, then this problem will be hard to work through.

But if you do know the sliding window technique, then it will be easier to code it out

and that technique is used in a lot of problems.

So the best way to get better with leetcode is to learn the core data strucutures and algorithms and learn the core patterns.

I highly suggest looking into neetcode’s roadmap

and if you have the money, maybe signing up for his courses.
But he also has a ton of content on his youtube channel where he breaks down leetcode problems.

You don’t want to grind leetcode and do random problem.
you want to instead focus on the core algorithms, data structures and patterns that come up all of the time.
That way you will be better equipped to solve whatever problem comes your way.

hope that helps

3 Likes

Thanks jwilkins I’m newbie to DSA . I will follow your advice…

1 Like

Happy to help.

I also struggled with leetcode when I first started.
it is a different way of thinking.

But with practice and learning the core concepts, then it does become easier.

Plenty of people struggled at first.

Including the guy who runs Neetcode

He too struggled with leetcode but kept working at it and was able to pass technical interviews and work at Amazon and Google.

So just take it day by day :+1:

2 Likes