To the Top
File:  root - text - article - 2020 - 01 - longest-consecutive-sequence.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 192 Views, 20503 Search Bots | 69 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Amazon:

You are given an array of integers. Return the length of the longest consecutive elements sequence in the array.

For example, the input array [100, 4, 200, 1, 3, 2] has the longest consecutive sequence 1, 2, 3, 4, and thus, you should return its length, 4.


def longest_consecutive(nums):
# Fill this in.

print longest_consecutive([100, 4, 200, 1, 3, 2])
# 4


Can you do this in linear time?
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 192 Views, 20503 Search Bots | 69 Words Subscribe to Feed Burner

Related Articles

  1. Most Frequent Subtree Sum
  2. Daily Interview Problem:Create a balanced binary search tree
  3. Daily Interview Problem: Tree Serialization
  4. [Daily Problem] Longest Increasing Subsequence
  5. CVE-2015-8874 - cPanel EasyApache Vulnerabilities
  6. Algorithm Interview: Shifted String
  7. [Daily Problem] Course Prerequisites
  8. Algorithm Interview: Permutations of numbers
  9. [Daily Problem] Longest Palindromic Substring
  10. Daily Interview Problem: Group Words that are Anagrams

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />