# Scala algorithm: Find minimum missing positive number in a sequence

Published , last updated

## Algorithm goal

Find the minimum missing positive number in a sequence.

For example, \([-3,-2]\) has no minimum missing positive as 1.

\([-3,1]\) has minimum missing positive number as \(2\).

\([-3,1,3]\) has minimum missing positive number as \(2\) as well.

## Test cases in Scala

## Algorithm in Scala

8 lines of Scala (compatible versions 2.13 & 3.0), showing how concise Scala can be!

## Explanation

Effectively, what we need to check is to find the first number in range (1 to <maximum positive number that is present>) that is not in the input list..

This means we compute the maximum positive number, and following that, get a set of all numbers (so we can check element presence quickly). (this is Â© from www.scala-algorithms.com)