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

Programming Exercises

Implement a function to calculate the maximum product of three numbers in an array.

Medium

Problem Statement

Implement a function to calculate the maximum product of three numbers in an array.

Sample Input

Array: [-10, -10, 5, 2]

Sample Output

Maximum product: 500

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun maxProductOfThree(nums: List<Int>): Int { // Add your code here to calculate the maximum product } fun main() { val nums = listOf(-10, -10, 5, 2) println("Maximum product: ${maxProductOfThree(nums)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
Array: [-10, -10, 5, 2]
Expected Output
Maximum product: 500