File: root - text - article - 2019 - 10 - longest-sequence-with-two-unique-numbers.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 308 Views, 18220 Search Bots | 54 Words
| Browse | Archive
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 308 Views, 18220 Search Bots | 54 Words
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Hi, here's your problem today. This problem was recently asked by Facebook:
Given a sequence of numbers, find the longest sequence that contains only 2 unique numbers.
Example:
Input: [1, 3, 5, 3, 1, 3, 1, 5]
Output: 4
The longest sequence that contains just 2 unique numbers is [3, 1, 3, 1]
Here's the solution signature:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 308 Views, 18220 Search Bots | 54 Words Given a sequence of numbers, find the longest sequence that contains only 2 unique numbers.
Example:
Input: [1, 3, 5, 3, 1, 3, 1, 5]
Output: 4
The longest sequence that contains just 2 unique numbers is [3, 1, 3, 1]
Here's the solution signature:
def findSequence(seq):
# Fill this in.
print findSequence([1, 3, 5, 3, 1, 3, 1, 5])
# 4
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Related Articles
- A trick for getting good at coding interviews FASTER
- [Daily Problem] Longest Increasing Subsequence
- Reverse a Directed Graph
- Daily Interview Problem: Arithmetic Binary Tree
- Daily Interview Problem: Count Number of Unival Subtrees
- Windows Scripting
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
- Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Skip the readings, focus on problems. And use all the hints!
- Daily Interview Problem: Merge List Of Number Into Ranges
©2006~2024 SteakOverCooked - 0.01118 Seconds(s) - 1672.372 KB/s - 34 Online
Memory: 494.02 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
![](/images/top.jpg)
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !