How difficult should Leetcode ACTUALLY be?

LeetCode is a few things.

  1. Identify the problem & solve generally

Read the problem. Look at the test cases. Look at the constraints. Try to identify the pattern or missing pieces to it. What is the real problem here? Is it the storyline they gave me, or is this some kind of counting problem or something? Once you have a plan, try to draw it out. I use an online whiteboard to think it out.

  1. Know your data structures

You have to know these really well. Know what each one does, how you implement it, why you would use any given one. It takes time to identify when to use one and when not to, but do your research. Look at the docs or sites available to your language about the data structures and learn what they do.

  1. Identify the data structure(s) that solve the problem & translate your solution into them.

Taking what you know of data structures & your solution you came up with, identify the best tool for the job. And make your solution. Then try it out and see if it passes. If it does, great, now you know how it works so you can optimize it.

  1. Identify time & space complexity

Once you know generally how fast / space efficient your program is operating, and you have a solution that works, you can work to try to reduce it and make it more efficient. This could take additional work from step 1 downward, in figuring out some more about data structures, re-identifying which one works, and applying, as well as tweaking your algorithm a bit.

It’s a practice thing. Make LeetCode your homepage on your browser and practice frequently.

Also look into common patterns such as two pointer, sliding window, etc. and see their associated algorithms.

/r/cscareerquestions Thread