To the Top
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 | 295 Views, 16717 Search Bots | 54 Words

Subscribe to Feed Burner | Browse | Archive
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:


def findSequence(seq):
# Fill this in.

print findSequence([1, 3, 5, 3, 1, 3, 1, 5])
# 4
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 295 Views, 16717 Search Bots | 54 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  2. Number of Ways to Climb Stairs
  3. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  4. [Daily Problem] Remove k-th Last Element From Linked List
  5. Daily Interview Problem: Find the k-th Largest Element in a List
  6. Most Frequent Subtree Sum
  7. Daily Interview Puzzle: Intersection of Linked Lists
  8. Spreadsheet Columns
  9. Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
  10. Daily Interview Problem: Validate Binary Search Tree

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />