Maximum Product of Three Numbers

Easy
23
1
62.0% Acceptance

In this lab, you are required to complete a function that finds the maximum product of three numbers in a given array of integers. The function, maximumProduct, accepts an array of integers called nums and returns the maximum product of any three numbers in the array. Here, you have to use ESM import/export for handling your code.

Example 1:

Input: nums = [1,2,3] Output: 6

Example 2:

Input: nums = [1,2,3,4] Output: 24

Example 3:

Input: nums = [-1,-2,-3] Output: -6

Notice how the array can contain both positive and negative integers, and the maximum product is not limited to the product of the largest three numbers in the array.

After implementing the function, work on the following challenges that will be used to test the correctness of your implementation:

  1. Challenge 1 - The function is successfully returning the maximum possible product.
  2. Challenge 2 - The function handles edge cases and provides the correct output for different input arrays.

To ensure an accurate and efficient evaluation of your code, pay close attention to the evaluation script. Make sure to completely write it without leaving anything incomplete or making any mistakes. Finally, keep in mind that the final length of the testlog array should match the number of challenges, and the order of the evaluation script should be in line with the order of the challenges presented.

Good luck! Feel free to reach out for any further clarification or assistance.

Make sure you're default exporting the function