Exodus Interview Question

How I would solve a specific algorithm