Loading...
Loading...
Loading...
Given a list of integers in any order, find the length of the longest run of consecutive values such as 4, 5, 6, 7. Duplicates are allowed and count once.
Example 1
Input
100 4 200 1 3 2
Output
4
1 2 3 4 is the longest run.
Example 2
Input
5 5 5
Output
1
Try the problem first. Open one hint at a time.
Put all the numbers in a set.
Start counting only from a number whose predecessor is not in the set.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor