diff --git a/leetcode/1464.MaximumProductofTwoElementsinanArray/maximumProductofTwoElementsinanArray.go b/leetcode/1464.MaximumProductofTwoElementsinanArray/maximumProductofTwoElementsinanArray.go new file mode 100644 index 0000000..433d1fc --- /dev/null +++ b/leetcode/1464.MaximumProductofTwoElementsinanArray/maximumProductofTwoElementsinanArray.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "sort" +) + +func maxProduct(nums []int) int { + sort.Ints(nums) + return (nums[len(nums)-1] - 1) * (nums[len(nums)-2] - 1) +} + +func main() { + nums := []int{3, 4, 5, 2} + fmt.Println(maxProduct(nums)) +}