#3732

Maximum Product of Three Elements After One Replacement

medium · 47.1% accepted · 78 likes · top 32%

array · math · greedy · sorting

⊣ practice⊣ open on leetcode ↗

Description

You are given an integer array nums.

You must replace exactly one element in the array with any integer value in the range [-105, 105] (inclusive).

After performing this single replacement, determine the maximum possible product of any three elements at distinct indices from the modified array.

Return an integer denoting the maximum product achievable.

Solution