Longest attendance streak

Write code · Medium · §6.2 Neighbors after sorting

days holds the day numbers on which a user checked in at a daily attendance event. The numbers are not necessarily in order, and if the user checked in several times on the same day, that day's number appears several times.

Complete the function solution, which returns the length, in days, of the longest period during which the user checked in every single day without missing one. If the user never checked in on two or more days in a row, return 1.

Function

solution(days)

Constraints

Examples

daysresult
[3, 1, 2, 6, 5]3
[14, 12, 13, 2, 25, 11]4

Starter code

def solution(days):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.