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, 22495 Search Bots | 89 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 483 Views, 22495 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, 22495 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
- 56 Bytes
- Daily Interview Question: Edit Distance
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Daily Interview Puzzle: Intersection of Linked Lists
- Algorithm Interview: Maximum Path Sum in Binary Tree
- Daily Interview Problem:Create a balanced binary search tree
- Number of Ways to Climb Stairs
- Daily Interview Problem: Min Stack
- Algorithm Interview: String Compression
- [Daily Problem] Longest Palindromic Substring
©2006~2024 SteakOverCooked - 0.0154 Seconds(s) - 1319.288 KB/s - 64 Online Memory: 493.88 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="index, 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 !