Dec 6, 2022
The only reason to ask a question in an interview is if you think it will predict the performance of the person you are interviewing in your organization.
I can't see anyway that this question has anything to do with people's performance as programmers. You can get this question entirely wrong, and be a very good programmer. You could get this question entirely right, and never have written a computer program at all.
Questions that do not test your skill for the job, but rather how closely you think like the person interviewing you: such questions are unfair, and also, will not find the best candidates. This is one such a question.