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 | 483 Views, 22502 Search Bots | 89 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 483 Views, 22502 Search Bots | 89 Words
| 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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 483 Views, 22502 Search Bots | 89 Words 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
Related Articles
- Daily Interview Problem: Contiguous Subarray with Maximum Sum
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Daily Interview Problem: Merge K Sorted Linked Lists
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Linode Support Ticket 10029540 - Other - Important Notice Regarding Ubuntu 17.10 Image
- Daily Interview Problem:Create a balanced binary search tree
- Consecutive Ones
- Making a Height Balanced Binary Search Tree
- Sorting a list with 3 unique numbers
- Daily Interview Question: Edit Distance
©2006~2024 SteakOverCooked - 0.01304 Seconds(s) - 4129.67 KB/s - 34 Online Memory: 516.09 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !