Headstorm Interview Question

coding challenge, algorithm