Pregunta de entrevista de Lowe's Home Improvement

dynamic Programming with segment tree