I've looked at and done a great many coding interview questions. Lots of them are quite bad, in that the candidate has to have a flash of intuition to solve them. Very few development jobs require frequent flashes of intuition.
That is, coding tests don't give interviewers what they need to see if someone can write code, and they often don't test anything but the most trivial coding skills.
Don't feel bad for yourself. These tests are terrible.