4 ms·
leetcode is testing a broad range of algorithm design concepts. It's an intellectually rich area, not boring or "thinking in one particular way". And it's an ar
by da39a3ee 5y ago
leetcode is testing a broad range of algorithm design concepts. It's an intellectually rich area, not boring or "thinking in one particular way". And it's an area of computer science that indeed does involve creativity.
To get started, first understand that leetcode problems fall into different categories: graph problems, "dynamic programming", double-pointer techniques, etc. And within those broad categories, there are families of problems. So first, stop trying to solve random leetcode and pick one family. How about "Best time to buy and sells stock"? Start with the easiest one. It won't be that easy! Don't worry if you can't solve it. Turn to the discussion where people post solutions, or the official solutions page, pick one solution in a language familiar to you that looks understandable, and study it. It might take an hour or more to understand what it's doing, but stick with it! Make notes, whatever helps you. But get to the point where you absolutely understand how that solution works.
Now, try to write it out from scratch without looking at the solution. And then, try to do the next one in the family. Keep notes for yourself on what your learning. And eventually you'll have learned how to do some graph algorithms, some "dynamic programming" (it's a silly name and a bit hard to define but it's a category) etc. This will all take weeks / months. But that's fine -- your learning the material of a couple of semesters in an undergrad CS course.
It's fun if you enjoy programming and algorithms, in my opinion. If you cannot sit down and learn like that then it is possible that you don't have the sort of mindset that the companies who are employing these tests are looking for.