3 ms·
It is very important to understand that you can't expect that your mind will work properly during an interview. So if you can't do it in your sleep then it isn'
by Klockan 12y ago
It is very important to understand that you can't expect that your mind will work properly during an interview. So if you can't do it in your sleep then it isn't good enough. There are only two ways to reach this stage, either it becomes second nature to you or you memorize everything. If you still want to proceed then you can try these steps:
Firstly you need to learn to code small 10-20 line programs in your head (everything including proper syntax etc, if you printed a copy of your mental image it would compile), without that you get crippled just from being unable to properly reason about your code.
Secondly you need to build up an intuition for data structures and algorithms so that you can easily come up with solutions on the fly. Very few do this, some even thinks that it is impossible and assumes that the questions only test memorization.
As an alternative to the second step you can memorize a ton of algorithms and continue going to interviews till you get a question you have memorized. This is what people usually do which isn't strange since this is how most pass their CS exams.
The first step is easy, just stop using your favorite IDE and use something simple like notepad. When you are comfortable with writing code in notepad then you are ready for interview programming.
The second step is harder and will take years. The easiest way to get better at this is to try to solve problems without help. You can start by reading up on different data structures/algorithms on wikipedia and then try to implement them in your favorite language. You can do competitive programming in parallel to practice speed and try out your implementations on tests which are much better at finding bugs than any interviewer.
The alternative second step can take any amount of time depending on how lucky you are. Minimum is to memorize FizzBuzz by writing it over and over in notepad till you get it right 20 times in a row. This can be done in a day even if you are an idiot. From there you can continue adding solutions to problems till you get the job you want. Then just forget everything and come back complaining once you want another job. This already happened once for fresh CS graduates since they forgot what they crammed for their tests so now they need to cram again and again for every interview.