To the Top
File:  root - text - article - 2019 - 11 - first-missing-positive-integer.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 180 Views, 17213 Search Bots | 89 Words

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

You are given an array of integers. Return the smallest positive integer that is not present in the array. The array may contain duplicate entries.

For example, the input [3, 4, -1, 1] should return 2 because it is the smallest positive integer that doesn't exist in the array.

Your solution should run in linear time and use constant space.

Here's your starting point:


def first_missing_positive(nums):
# Fill this in.

print first_missing_positive([3, 4, -1, 1])
# 2
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 180 Views, 17213 Search Bots | 89 Words Subscribe to Feed Burner

Related Articles

  1. Algorithm Interview Question: Find the Single Element in an Array of Duplicates
  2. 56 Bytes
  3. Plus One
  4. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  5. Consecutive Ones
  6. Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
  7. PHP Unit Tests on VPS Server
  8. Daily Interview Problem: Largest Product of 3 Elements I
  9. Daily Interview Problem: Look and Say Sequence
  10. [Daily Problem] Witness of The Tall People

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" />