题目:
题解:
func longestConsecutive(nums []int) int {numSet := map[int]bool{}for _, num := range nums {numSet[num] = true}longestStreak := 0for num := range numSet {if !numSet[num-1] {currentNum := numcurrentStreak := 1for numSet[currentNum+1] {currentNum++currentStreak++}if longestStreak < currentStreak {longestStreak = currentStreak}}}return longestStreak
}