First missing positive number
MediumGive an array of numbers, find the first missing positive number.
Examples
first_missing_positive([-3, 4, 1])
should return2
.first_missing_positive([0, 2, 1, 4])
should return3
.first_missing_positive([-5, 1, -2, 2, 3])
should return4
.first_missing_positive([2, 1, 3, 4])
should return5
.
Try it first
Solution
6 Essential Hash Tables Coding Interview Problems
Master Hash Tables by trying the coding challenges below.
- 1.Two sumEasy
- 2.Palindrome CheckEasy
- 3.Cover SetMedium
- 4.Missing numberMedium
- 5.Crypto ExchangeMedium
- 6.Distinct SubarrayHard