文件: root - text - article - 2019 - 10 - longest-sequence-with-two-unique-numbers.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 557 次阅读, 20569 次搜索 | 54 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 557 次阅读, 20569 次搜索 | 54 个单词
| 浏览 | 博客存档
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:
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 557 次阅读, 20569 次搜索 | 54 个单词 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
猜您喜欢...
- Design Tic-Tac-Toe
- Algorithm Interview Question: H-Index
- Spreadsheet Columns
- Daily Interview Problem:Create a balanced binary search tree
- Sort a Partially Sorted List
- Two Tricks of Delphi
- Daily Interview Problem: Spiral Traversal of Grid
- PHP Unit Tests on VPS Server
- Daily Interview Problem: Jump to the End
- Compare Version Numbers
©2006~2024 牛排过熟 - 0.00879 秒 - 2217.754 KB/s - 34 在线 内存: 492.08 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。