#3745
Maximize Expression of Three Elements
easy · 72.4% accepted · 52 likes · top 82%
array · greedy · sorting · enumeration
Description
You are given an integer array nums.
Choose three elements a, b, and c from nums at distinct indices such that the value of the expression a + b - c is maximized.
Return an integer denoting the maximum possible value of this expression.
Solution