← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Problem Statement
Given an integer array nums, find three numbers whose product is maximum and return the maximum product. The numbers do not need to be consecutive.[1][2][9]
Examples
Input: nums = [1,2,3]
Output: 6
Explanation: 1 × 2 × 3 = 6[2][4][1]
Input: nums = [1,2,3,4]
Output: 24
Explanation: 2 × 3 × 4 = 24[7][1]
Input: nums = [-1,-2,-3]
Output: -6
Explanation: -1 × -2 × -3 = -6[1][7]
Additional cases from sources:
nums = [-4,-3,-2,1,5] (sorted: same)60-4 × -3 × 5 = 60[1]nums = [-5,-7,9] (or similar like [4,5,-19,3])315 or 60-5 × -7 × 9 = 315; 4 × 5 × 3 = 60[3]Constraints
3 <= nums.length <= 10^4-1000 <= nums[i] <= 1000[7]