GigglyHamster
GigglyHamster

To folks who can solve LC Hards

What did it take to get to that point? I'm reasonably comfortable with mediums but hard problems feel like a few notches above in difficulty. Should I find the equivalent rating of mediums on codeforces and work from there? Or is it better to keep reading LC hard solutions until something clicks?

31mo ago
Talking product sense with Ridhi
9 min AI interview5 questions
Round 1 by Grapevine
WobblyBiscuit
WobblyBiscuit
Droom32mo

A new strategy I have been trying is to look at LC hard questions. Try to think of the solution. Most of the time I can't, so I look up a few solutions and study it until I understand the intuition. Then, I move on to other questions. Then I circle back to the same questions at least a few weeks later. I've found that the time gap lets me forget the code in the solution but I still remember the intuition and I can still solve it. This causes me to start seeing the patterns slowly over time

FluffyBagel
FluffyBagel

A lot of the problems build on top of each other. If you have already solved the easy and medium difficulty for a line of problems, the hard might come naturally. Just keep solving problems. You benefit more from the ones you solve yourself first before looking up the optimal solution.Having said that, there are problems that you will most likely not just come up with the solution. There are algorithms that were invented long ago and are taught in CS courses. Even some easy ones, say bubble sort, you would most likely not come up with them by your own. You need to do some research for those. See the comment, find what algorithm people are recommending, look it up and learn it

BouncyJellybean
BouncyJellybean

I did competitive programming back in highschool. Nothing world class, but reached Master on codeforces (2100ish rating) and solved around 500 problems on CF. Now when I try leetcode,most of the problems (including LC hards) are like easy version of some problem I did before.I guess if you get serious about cp you can get to this level, although it's probably not optimal strategy.

MagicalQuokka
MagicalQuokka

While it sounds good in theory I do think it's not optimal like u said. The lower level divisions for beginners are not your typical LC questions you'll see at all (number theory, puzzles, etc).Sounds good in theory but there's better ways as far as interview prep.I do still enjoy competitive programming though. Scratches the gaming/ puzzle itch I have.

JazzyNoodle
JazzyNoodle

I'll add that often times the question might require specific domain knowledge about the problem. So unless you've had past experience solving that specific type of problem there might be some assumed knowledge. There are some LC Hards that even after looking at several solutions and YT videos I still do not see how I would even come close to deriving anything near the correct answer. Like I could understand the algorithm/pattern that they use, but a lot of work is done before the actual coding starts.

SleepySushi
SleepySushi

Man, I see a future Google employee in you

SquishySushi
SquishySushi

Even hards follow a pattern. Memorize the patterns.

JumpyHamster
JumpyHamster

I think it depends as LC hards can be hard for multiple reasons. I feel like, most of the time, they're hard because there are difficult edge cases to account for.Take problems like Alien Dictionary or Word Search II. Even when you understand the problem and what the ideal solution is, it can be tricky to code as accounting for edge cases is non-trivial.In other cases, the problem could have multiple solutions, but to get the most optimal, it may require knowing a "math trick" or a lot of practice to recognize the pattern and the different approaches you could use.There are many problems that initially look like knapsack problems and can be solved using a DP approach, but that's actually the slower approach and you could solve it faster with a priority queue or something like that. Course Schedule III i think is an example of this.But in the case of an interview, it can be "good enough" to know one solution even if it isn't the most optimal

PrancingBagel
PrancingBagel

Taking a break. Working 1-2 hours a day is not doable in better companies.

Discover more
Curated from across