My Mental Health Just Got Destroyed by an Algorithm Problem (LeetCode Hard)
Today I took on the LeetCode Hard problem 'Median of Two Sorted Arrays' and gave up after 3 hours. I understand the concept of binary search, but the index handling was so complicated I felt like my head was going to explode. In the end, it took me an hour just to understand the solution. I've heard people say 'Hard problems don't come up' when preparing for job interviews, but I still feel inadequate and it's been eating at me. How do you all manage your mental health while studying algorithms? Does it get better if you keep at it consistently?
10 answers
LeetCode Hard problems will blow you up at first. I mainly focus on Medium and occasionally challenge Hard, but even 3 hours is a decent effort. Mental management tip: set a time limit when solving Hard, and if you can't solve it, boldly look at the solution and focus on understanding. If you keep at it, you'll definitely improve!
Have you ever tried drawing out the concept of partitioning? When I get confused about indices, I find it helps to actually sketch out the array. Still, Hard problems are meant to be tough, so don't beat yourself up. If you keep at it, you'll definitely feel yourself improving!
Oh man, I've been there too—that problem totally wrecked my mental state... Applying binary search to two arrays at the same time turned out to be way trickier than I expected. But honestly, understanding the solution is a skill in itself! I just keep grinding with the mindset of 'one more problem and I'll improve.'
I solved 100 Medium problems and even tried Hard, but I still got wrecked lol. I just moved on thinking, 'Learned something new today.' When I talk to other job seekers, they all have similar experiences. Let's hang in there together!
Don't think you lack skill. That problem is considered a top-tier difficulty on LeetCode too. I only managed to memorize and solve it after reviewing it about three times. What matters is not giving up and keeping at it!
I've had a similar experience. That problem is famously tricky, so it's totally normal not to solve it on the first try. I just noted it as a new type and revisited it a week later. Hard problems rarely appear in job coding tests, so don't stress too much.
I think LeetCode Hard problems are best used for studying slowly without time pressure. For me, it helped to analyze them with curiosity, asking 'Why did they solve it this way?' And the saying 'Hard problems don't come up in interviews' is actually somewhat true. Have confidence!
Mental Health Tips: Organize Your Thoughts While Exercising! When I get stuck on an algorithm problem, I go for a 30-minute walk. And thinking 'It's normal not to solve a Hard problem within the time limit' makes me feel more at ease. Fighting!
I've been thinking about something similar lately! But yesterday I solved 'Container With Most Water' (Medium) and it made me feel great. I think it's important to feel small achievements often. Tackling Hard problems occasionally while consistently working on Medium ones will help improve your skills. Fighting!
Oh man... I also spent 2 hours on that problem and gave up. But later I realized there were tons of edge cases due to index handling. Just understanding the solution is a big improvement! Next time a similar type comes up, it'll be much easier.