SimSpace interview question

Solve a LC-style algorithm problem.