Once I had a candidate struggle with my screening question, flattening an array of nested arrays, and that’s fine because I normally use that as an opportunity to see how they ask questions and work together on finding a solution. But the candidate went silent for about 5 minutes and then came back with a perfect solution, using iterators, which are a pretty obscure JavaScript feature. I later found that exact code block on the MDN site, and I was pretty shocked at how brazen an action it was, because if they had just asked for direction and admitted they were struggling they could have still passed the interview.
This. Everyone in the thread is claiming no wrongdoing on the part of the author. If I was in this position, I would excitedly inform the interviewer that I had seen the question before and then quickly write down the answer. But that would look be a lot less impressive than OP’s acting as he pretended to come up with the perfect answer on the fly.