Three main reasons 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, it is unlikely you have heard about prime numbers, integer division or remainder operations since the high school.
2) The second reason is that whiteboard exercises use different software patterns than you are used to on your day-to-day job. Recursion is a big one! If you use languages like Java, Kotlin, Python, etc., the 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. Coding interviews often use recursion.
3) The third reason is the belief that it’s not worth practising whiteboard code exercises. Some people believe they test innate characteristics such as smartness, or the ability to react to unpredictable circumstances. Nothing could be furthest from the truth. There’s a surprisingly high probability you will find the exercises you practised in the real interview. Even if that’s not the case, programming problems used on interviews follow typical patterns and algorithms. You will notice a significant improvement within a couple of days.
So start practising now.