Maximum Product of Three Numbers
Choose three numbers from three different positions of nums so that their product is as large as possible. Return that product.
Negative numbers can help: two negatives multiply to a positive.
Example 1
nums [1,2,3,4]
returns 24
2*3*4 = 24.
Example 2
nums [-10,-10,1,3]
returns 300
(-10)*(-10)*3 = 300.
Constraints
3 <= len(nums) <= 30-100 <= nums[i] <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.