Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a function to find the smallest missing positive integer in an array.

Medium

Problem 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)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
Array: [3, 4, -1, 1]
Expected Output
Smallest missing positive integer: 2