Garmin interview question

About the assignment solution and space complexity of the solution