Would this be something you'd do in a real-world situation? Or would you question the requirements and the need for such a feature?
I'd be doing the latter, so why should I have to behave differently during an interview?
I'd be doing the latter, so why should I have to behave differently during an interview?
If this is not what the interviewer wanted, they'd be better served by asking a slightly more fantastical question that would still show problem-solving skills. Also, the interviewer should qualify the question by saying that "this isn't a real world situation, I just want an algorithm". I don't know how someone would react to that situation.