Black Box interview question

Logical algorithm 3 question