A situation nearly every computer scientist will face at some point is a coding interview. A group of people are watching you while you code in the most unnatural programming environment you could think of: A whiteboard. At least for many interviews this is the case. In that regard you do not only need coding skills but also a habit of talking through your solutions and being able to present them in a way that makes you look as smart as possible.
The best way to prepare for coding interviews is, well, by going to coding interviews. Or by going to mock interviews with your friends if you find that too nerve wracking. I used to run those with a couple of PhD student colleagues while I was finishing up my studies. It was great training and, once we started bringing beer, much more fun than expected.
A book to help you find good coding exercises is Cracking the Coding Interview by Gayle Laakmann McDowell. It is in fact, recommended by Google if you want to go to an interview with them. It has tons of typical questions including solutions and approaches to solve them. Additionally, it has some introductory chapters about prepping your CV and presenting yourself to the interviewer.