Create a function to find the smallest missing positive integer in an array.
MediumProblem Statement
Create a function to find the smallest missing positive integer in an array.
Sample Input
Array: [3, 4, -1, 1]
Sample Output
Smallest missing positive integer: 2
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun findSmallestMissingPositive(nums: List<Int>): Int {
// Add your code here to find the smallest missing positive integer
}
fun main() {
val nums = listOf(3, 4, -1, 1)
println("Smallest missing positive integer: ${findSmallestMissingPositive(nums)}")
}
Input
Array: [3, 4, -1, 1]
Expected Output
Smallest missing positive integer: 2