文件: root - text - article - 2019 - 10 - longest-sequence-with-two-unique-numbers.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 555 次阅读, 20491 次搜索 | 54 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 555 次阅读, 20491 次搜索 | 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, | 英文 | 主页 | 类别: 计算机科学 | 555 次阅读, 20491 次搜索 | 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
猜您喜欢...
- Progess made
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Maximum In A Stack
- Find Pythagorean Triplets
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- Daily Interview Problem: Validate Binary Search Tree
- First and Last Indices of an Element in a Sorted Array
- Windows Scripting
- Binary Tree Level with Minimum Sum
- Daily Interview Problem: Running Median
©2006~2024 牛排过熟 - 0.00747 秒 - 2705.625 KB/s - 42 在线 内存: 494.02 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)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。