It’s definitely not an exact science.
1. I try to make the parameters of the interview as friendly as possible — language of their choice, don’t have to worry about code style or computational complexity, or talk while they’re coding, just write working code that solves the problem. They can use google freely. I’m there as a resource to talk through their solution, answer questions, and help them get unstuck if needed.
2. The algorithm to solve the question doesn’t require a trick and there are many viable solutions so most candidates can verbally explain to me a working algorithm quickly, +- a couple edge cases.
3. Candidates often get visibly flustered or hung up on irrelevant details, or unsure what exactly I want for them, and I focus on noticing this. I try to guide them down a correct path if they’re close and tell them not to over-architect if they start doing that.
Despite all this, too manly candidates do not have a dependable metaprocess for writing working code - a common scenario is they write code, it gives the wrong result, they drop some print statements to debug, but can’t effectively trace the program to figure out why they’re getting the debug output and so they guess and try to fix the wrong thing, causing further problems. I know that some of this is nerves but it can’t account for all of it.