Find Missing Least Positive Element From Array

Published by Jass in

Create a function that returns an array of missing least positive element(s) from a given array. Resulted array can not contain 0 or negative numbers.

Examples

getLeastPositiveElements([3, 4, -1, 1]) ➞ [2]

getLeastPositiveElements([3, 4, 6, -1, -3,1]) ➞ [2, 5]

getLeastPositiveElements([1, 8, 6, -1, -9,1]) ➞ [2, 3, 4, 5, 7]

Notes

Please check example for clarification

Watch a quick demo on how Edabit works.