题目
思路:https://leetcode.cn/problems/longest-consecutive-sequence/solutions/2362995/javapython3cha-xi-biao-ding-wei-mei-ge-l-xk4c/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public int longestConsecutive(int[] nums) {
Set<Integer> set = new HashSet<>();
for (int num : nums) {
set.add(num);
}
int len = 0, maxLen = 0, tmp;
for (int num : set) {
tmp = num;
if (!set.contains(num - 1)) { // 序列起点
len = 1;
while (set.contains(++tmp)) {
++len;
}
maxLen = maxLen > len ? maxLen : len;
}
}
return maxLen;
}
}


![[蓝桥杯 2019 省 B] 特别数的和-C语言的解法](https://img-blog.csdnimg.cn/65eed59a4f1044378c95f3d03e7d3cd1.png)






![[论文阅读]Generalized Attention——空间注意力机制](https://img-blog.csdnimg.cn/direct/07f66202a6d842c5b395748444d84719.png)









