You are given an integer array
pizzas
of sizen
, wherepizzas[i]
represents the weight of theith
pizza. Every day, you eat exactly 4 pizzas. Due to your incredible metabolism, when you eat pizzas of weightsW
,X
,Y
, andZ
, whereW <= X <= Y <= Z
, you gain the weight of only 1 pizza!
- On odd-numbered days (1-indexed), you gain a weight of
Z
.- On even-numbered days, you gain a weight of
Y
.Find the maximum total weight you can gain by eating all pizzas optimally.
Note: It is guaranteed that
n
is a multiple of 4, and each pizza can be eaten only once.
1 | class Solution { |