ByteByteGo logo
menuProblems List

Longest Chain of Consecutive Numbers

Medium

Find the longest chain of consecutive numbers in an*array. Two numbers are consecutive if they have a difference of 1.

Example:

Input: nums = [1, 6, 2, 5, 8, 7, 10, 3]
Output: 4

Explanation: The longest chain of consecutive numbers is 5, 6, 7, 8.

You can practice coding exercises online by logging into bytebytego.com on your laptop.