Stack Bash - Master data structures and algorithms

First missing positive number

Medium
Give an array of numbers, find the first missing positive number.

Examples

  1. first_missing_positive([-3, 4, 1]) should return 2.
  2. first_missing_positive([0, 2, 1, 4]) should return 3.
  3. first_missing_positive([-5, 1, -2, 2, 3]) should return 4.
  4. first_missing_positive([2, 1, 3, 4]) should return 5.

Try it first

Solution

6 Essential Hash Tables Coding Interview Problems

Master Hash Tables by trying the coding challenges below.
  1. 1.Two sumEasy
  2. 2.Palindrome CheckEasy
  3. 3.Cover SetMedium
  4. 4.Missing numberMedium
  5. 5.Crypto ExchangeMedium
  6. 6.Distinct SubarrayHard

Want to confidently pass your next coding interview?

Stack Bash helps new and veteran software engineers master data structures and algorithms for technical interviews.