Garmin Interview Question

About the assignment solution and space complexity of the solution