ntree.ai
ntree.aiMaximum Product of Three Numbers

Maximum Product of Three Numbers

easysolvedattempted

Given an integer array nums, choose three numbers whose product is the largest possible one, and return that product.

Example 1:

Input:  nums = [2, 5, 1, 4, 3]
Output: 60
Explanation: 3 * 4 * 5 = 60.

Example 2:

Input:  nums = [3, -10, 4, -5, 2]
Output: 200
Explanation: -10 * -5 * 4 = 200.

Constraints:

  • 3 <= length of nums <= 10^4
  • -1000 <= nums[i] <= 1000
def maximumProduct(nums: list[int]) -> int:
pass
 

Press Visualise to step through your code.