There are three main reason that explain why even the most experienced developers struggle with coding interviews:
1) The first reason is that code interview exercises often rely on maths. Unless you design hardcore algorithms, chances are that you haven’t heard about prime numbers, integer division or reminder operations since the high school.
2) The second reason is that whiteboard exercises use different patterns than the ones you are used to on your day-to-day job. Recursion is a big one! If you use an imperative language like Java, chances are that you never implemented a recursive solution in your professional life. Recursion is a bit more common in functional languages like Scala, but its use in production code is controversial. Recursion is very often used on coding interviews.
3) The third reason is the belief that it’s not worth practicing whiteboard code exercises. Some people believe they test innate characteristics such as smartness or the ability to react on unpredictable circumstances. In fact, nothing could be furthest from the truth. There’s a surprising high chance that you’ll find exactly the same exercises in practice and in the real interview. Even if that’s not the case, exercises used on interviews follow common patterns and algorithms. You will notice a significant improvement within a couple of days.
So start practicing now.