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, 22488 Search Bots | 89 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 483 Views, 22488 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, 22488 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:Create a balanced binary search tree
- Daily Interview Problem: Find the k-th Largest Element in a List
- CPU Utilization
- Daily Interview Problem: Maximum Profit From Stocks
- Daily Interview Problem: 3 Sum
- Daily Interview Question: Word Search
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Consecutive Ones
- [Daily Problem] Longest Palindromic Substring
- Most Frequent Subtree Sum
©2006~2024 SteakOverCooked - 0.00915 Seconds(s) - 2170.115 KB/s - 38 Online Memory: 492.28 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 !