4 ms·
Think of the leetcode site as a set of practice problems. If you're struggling to solve a problem, then that shows what you should study to become better at lee
by lostdog 5y ago
Think of the leetcode site as a set of practice problems. If you're struggling to solve a problem, then that shows what you should study to become better at leetcode. In your case, maybe the O(n) algorithm is a pattern that's broadly applicable to other problems too.
I think that if you're stuck on a problem for more than 30 minutes, it's better to go read the solution and learn from it than to keep struggling. (Then go back a week later and see if you can solve the problem from memory).
Opinions certainly differ on whether leetcode makes for a good interviewing process. On your specific problem, there are a ton of similar problems where you need to traverse possible solutions in a particular order to be efficient. I regularly see similar problems at work.
- b20000 5y ago“solve the problem from memory” - there you have it
- nowherebeen 5y agoThat's the truth, ain't it. These algorithms didn't just poof out of nowhere. Some of them took years to figure out. But somehow, people aren't smart if they can't regurgitate the optimum solution in 20 minutes. Despite the fact, some of them already work in FANG. Here's the truth, there are over >200 people that apply for a single FANG job. Don't believe me? Buy LinkedIn premium and find out yourself. Talk to a Fang recruiter. Leetcode is just a way to filter people down to 5. It reflects nothing on your intelligence other than willingness to be a lemming that receives >200k per annum.
- leetthrowaway 5y ago> I regularly see similar problems at work. No way anyone gets that in 30 minutes without having seen it exactly before. Moving pointers in from the sides, according to Y height, both at the same time when equal, and then not using that to find the solution, just to narrow the search space? I mean, it's not like I and everyone else didn't think along those lines, but that exact algorithm is totally non-obvious. I spent like 20 minutes on something similar, another 20 on a recursive split/merge thing that went nowhere, then got brute force working.
- jstx1 5y agoThe problems can be solved quickly with training. There’s a limited number of techniques and you develop pattern recognition with practice. Once you get that down it’s about executing well under pressure and communicating your thought process.
- b20000 5y agono, they can be solved quickly by memorizing the optimal solution and training to write the code very quickly. so basically train like a monkey.