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 | 152 Views, 16008 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 | 152 Views, 16008 Search Bots | 89 Words Subscribe to Feed Burner

Related Articles

  1. Find Pythagorean Triplets
  2. Daily Interview Problem: Merge K Sorted Linked Lists
  3. Daily Interview Question: Create a Simple Calculator
  4. Design Tic-Tac-Toe
  5. Autorun.inf Virus Protection
  6. Daily Interview Question: Word Search
  7. Making a Height Balanced Binary Search Tree
  8. Spreadsheet Columns
  9. Spreadsheet Column Title
  10. Two Tricks of Delphi

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />