SimSpace Interview Question

Solve a LC-style algorithm problem.