Table of contents
No headings in the article.
As a beginner on LeetCode, it can be hard to know where to start. When faced with a problem that you are unsure of how to solve, should you invest time trying to solve it or check solutions?
On one hand, spending time trying to solve the problem on your own can be a great way to build up your problem-solving skills.
On the other hand, looking at other people's solutions can help you learn new techniques and approaches, understand the problem better and get new ideas to solve it.
The best approach when starting on LeetCode is to first try to solve the problem on your own. Take a good look at the problem statement, try to understand it and come up with a plan of action. If you find yourself stuck use your notepad, it's very helpful to visualize the problem better. Like below :
Creating a set of rules for yourself can be a helpful way to manage your time and stay focused while solving LeetCode problems. Here are a few possible rules you can consider:
If you spend 10 minutes trying to solve a problem and you still don't have an idea how to do it, take a look at the "Hint" section. This can often provide a useful starting point to help you move forward.
If you're still stuck after looking at the hint section, try using the "Discussion" section. This can be a great way to learn from other people's approaches and get new ideas on how to solve the problem.
If you can't solve the problem within 30-45 minutes, take a look at the solutions. However, you should avoid copying the solution and try to understand the logic behind it. This can be a great way to learn new techniques and approaches.
My advice to you is to practice, practice, practice. Keep working through problems and experimenting with different approaches. This will not only help you build your problem-solving skills. Remember that practice is key, and the more you practice, the better you'll get.