Challenge: Smallest Positive Missing Number

Let’s find the smallest positive missing number in this challenge.

Problem

Given an unsorted array, find the smallest positive number missing in the array. Consider 1 as the smallest positive number.

Input

An integer array.

Output

A missing integer. Otherwise -1 if not found.

Sample input

array = { 8, 5, 6, 1, 9, 11, 2, 7, 4, 10 }

Sample output

missing number = 3

Let’s check the illustration below to better understand the question.

Get hands-on with 1400+ tech skills courses.