力扣西小白刷題之128題最長連續序列

題目描述 給定一個未排序的整數數組,找出最長連續序列的長度。 要求算法的時間複雜度爲 O(n)。 思路 哈希表 參考自:https://leetcode-cn.com/problems/longest-consecutive-sequence/solution/zui-chang-lian-xu-xu-lie-by-leetcode-solution/ 我們考慮枚舉數組中的每個數 x,考慮以其爲起
相關文章
相關標籤/搜索