Black Box Interview Question

Logical algorithm 3 question