Don’t spend more than 15 minutes stuck on a question!
(At least when you are starting your prep)
If you are stuck for more than 15 minutes in the beginning, just look at the solution.
Do this for 50 questions or so. You will start seeing patterns.
Just like any other skill, it takes time to get good at these questions.You learn the different tricks to solve them. Eventually, you will be able to apply these techniques to more and more problems. They will become second nature to you.
Here are a few more tricks I recommend:
1.Practice on Paper
Just like a whiteboard, draw out different examples. Write the code on paper too. Writing code on paper prepares you better for whiteboarding.
2. Write code, don’t just look at the solution
Write the solution in your language of choice. Coding practice is the #1 thing you need at the beginning.
3. Repeat the same code
Repeat the solution twice on paper. Yes, twice.
The first time you repeat it, you get comfortable with the solution. The second time, it becomes second nature to you. Don’t memorize the code, get comfortable with its logic.
4. Practice the same problem 3 days later, then a week later
Utilize exponential backoff in your memory. A lot of candidates implement code only to realize they are back to square one after a month. Make sure you solve the same problem again in a few days.
Most importantly, try to distill techniques common to many problems. You will start seeing patterns you can practice.
And if you want a structured course with these techniques, check out InterviewCamp.io
Our original answer on Quora