func max(a, b int) int {
if a > b {
return a
}
return b
}
func maximumProduct(nums []int) int {
sort.Ints(nums)
return max(nums[0]*nums[1]*nums[len(nums)-1], nums[len(nums)-1]*nums[len(nums)-2]*nums[len(nums)-3])
}
Runtime: 64 ms, faster than 32.94% of Go online submissions for Maximum Product of Three Numbers.
Memory Usage: 6.3 MB, less than 100.00% of Go online submissions for Maximum Product of Three Numbers.
Runtime: 100 ms, faster than 59.67% of JavaScript online submissions for Maximum Product of Three Numbers.
Memory Usage: 38.3 MB, less than 100.00% of JavaScript online submissions for Maximum Product of Three Numbers.
Runtime: 312 ms, faster than 74.30% of Python3 online submissions for Maximum Product of Three Numbers.
Memory Usage: 14.9 MB, less than 6.67% of Python3 online submissions for Maximum Product of Three Numbers.