Longest Consecutive Run

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • medium
  • Pro

Given an unsorted list of integers, find the length of the longest run of consecutive values, such as four, five, six and seven, which may appear in any order in the list. Explain how to do it in linear time.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →