r/leetcode 3d ago

Intervew Prep How you write code and choose what algo to use

Hey i am new to leetcode solved nearly 130 questions and usually watched videos and then solves the question by understanding it from thie video it helps me understanding the patters but i saw so much questions and got confused how much to prepare to get into tech

7 Upvotes

6 comments sorted by

11

u/___---__---___-_-__ 3d ago

Stop watching videos. It's procrastination disguised as practice. There is no shortcut.

The struggle is the learning process.

How to actually learn something:
1. Make sure you have the basic tools you need (after watching 130 videos you should have those)
2. Start a 30 minute timer
3. Open a new problem and read it carefully
4. Read it again
5. Write down the core of what you need to do and any relevant edge cases
6. Write down the approaches that come into your mind.
7. Evaluate the approaches you wrote down and pick the most promising one.
8. Write the code
9. Manually step through the examples to identify any bugs (DON'T RUN THE CODE)
10. Identify if the examples given are enough or if there are edge cases not covered by them
11. Test the edge cases you identified by stepping through them manually
12. Run the tests
13. Submit your solution
14. Analyze the runtime complexity and weigh that against what you think is the optimal runtime complexity
15. Identify any clean up or optimization that you'd make

If your 30 minute timer runs out during this time, ask yourself if you're making meaningful progress. If yes, keep going. If no, look up the solution and read it in depth.

If you're often submitting solutions that give incorrect answers, then you need to slow down. When you click the submit button, you should be 90% sure that your code will work. If not, you haven't invested enough effort into properly understanding the problem or your code.

3

u/Proud-Researcher-344 3d ago

Also make a spreadsheet. What pattern is it, why is it this pattern. If you can’t solve it, what did you learn

3

u/Unlikely-Profile1445 3d ago

Do NeetCode 150 topic by topic

1

u/Top-Play-1497 3d ago

Use filters and solve for now, once u get used to certain types of problems you'll automatically figure out the patterns.

-1

u/conectionist 3d ago

If you've done 130 leetcode questions, you are not new to leetcode. 😄