Added maxSequence solution