Whiteboard interviews are a good way to evaluate these skills - assuming the candidate hasn't seen this particular problem before and the interviewer understands that this is what they're supposed to look for.
Goodhart's law applies - the measure becomes a target and it ceases to be a good measure.
People who have weak problem solving skills or poor abilities to form mental models still want high paying software jobs so they "grind leetcode" until they can pass these interviews.
Then over time these grinders get high enough up they start becoming interviewers themselves and they don't understand that they're even supposed to screen for talent, they conduct the interview like a memory test since to them that's what it was.
In spite of this, there's no better interview type I've seen proposed given the constraints most companies are under (don't waste candidate's time, have a consistent rubric that HR likes, etc.) so for now we're going to keep using it.