Question d’entretien chez Amazon

find the maximum sequence with segments