John Deere interview question

general approach for a solution