Tap here to switch tabs
Problem
Submissions

Problem: Longest Consecutive Sequence

Longest Consecutive Sequence asks you to find the length of the longest run of consecutive integers in an unsorted array, including negative values and elements in any order.

Statement

Given an unsorted array, nums, your task is to return the length of the longest consecutive sequence of elements. The consecutive sequence of elements is such that there are no missing elements in the sequence. The consecutive elements can be present anywhere in the input array.

Note: Two elements, xx and yy, are called consecutive if the difference between them is equal to 11.

Constraints:

  • 0≤0 \leq nums.lengths ≤103\leq 10^{3}
  • −106≤-10^{6} \leq nums[i] ≤106\leq 10^{6}
⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Consecutive Sequence

Longest Consecutive Sequence asks you to find the length of the longest run of consecutive integers in an unsorted array, including negative values and elements in any order.

Statement

Given an unsorted array, nums, your task is to return the length of the longest consecutive sequence of elements. The consecutive sequence of elements is such that there are no missing elements in the sequence. The consecutive elements can be present anywhere in the input array.

Note: Two elements, xx and yy, are called consecutive if the difference between them is equal to 11.

Constraints:

  • 0≤0 \leq nums.lengths ≤103\leq 10^{3}
  • −106≤-10^{6} \leq nums[i] ≤106\leq 10^{6}