Amazon interview question

find the maximum sequence with segments