Maximum Product of Three Numbers

Given an integer array nums, find three numbers whose product is maximum and return the maximum product.

Example 1
Inputnums = [1,2,3]
Output6
The maximum product is obtained by multiplying 1, 2, and 3.
Example 2
Inputnums = [1,2,3,4]
Output24
The maximum product is obtained by multiplying 2, 3, and 4.

Constraints

  • 3 <= nums.length <= 10^4
  • -1000 <= nums[i] <= 1000

Asked at 15 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate