Pregunta de entrevista de N26

Medium level DP problem - hills and valleys