A Snapstreak counts consecutive days on which two friends both sent a Snap. You get the dates on which a pair snapped each other, as "YYYY-MM-DD" text, in any order and possibly repeated. Write longest_streak(days) returning the length of the longest run of consecutive calendar days. An empty list is a streak of 0.
Example
longest_streak(["2025-01-03", "2025-01-01", "2025-01-02", "2025-01-05"])
3
What this question tests
Tests consecutive runs over real calendar dates: month ends, leap days, New Year and repeated days. The set-based scan (only start counting at a day whose previous day is missing) is the efficient answer to "longest consecutive sequence" and the one interviewers hope to see.
More Python interview questions