I've seen interviewers pose problems that took the likes of Dijkstra and Knuth years to solve the first time, yet somehow they expect candidates to solve two of them in 45 minutes. Unless you are actually Dijkstra reborn or Knuth you're unlikely to solve a problem of this type quickly unless you've seen it, or something very close to it, before.
So it's essentially selecting for some combination of how recently you took an algorithms course or qualifying exam, how comprehensive that course of study was, how much experience and success you have had in "programming" (aka algorithm puzzle) competitions, how much grinding you've done on hackerrank/leetcode/etc., and pure luck.
That being said, I suppose much of the content of medical boards or the bar exam has little to do with the actual practice of medicine or law, so I guess computing is not alone in terms of annoying hoops it makes people jump through. I just wish that algorithms qualifying exams were a standard thing that you could pass outside of a job interview and be done with, rather than something you have to suffer through repeatedly.