prices, and the number of items is a multiple of 4. Each day you put together a lot of exactly four items that have not been handed out yet, and you keep one of them:
- on odd days (1st, 3rd, …), the most expensive item of the lot;
- on even days, the second most expensive one (if the lot's prices sorted are a ≤ b ≤ c ≤ d, you get c).
This goes on until no items remain. Return the largest total value you can keep.prices=[3, 9, 1, 4, 8, 2, 6, 5] → 15
Day 1: lot [1, 2, 3, 9], you take 9. Day 2: lot [4, 5, 6, 8], you take 6. Total 15.
prices=[7, 7, 7, 7] → 7
There is a single day, and it is odd: you take the priciest item, 7.
prices=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] → 32
prices=[3, 9, 1, 4, 8, 2, 6, 5]
15
Run checks the first 3 tests in your browser. Submit checks all 92 tests on the server, hidden ones included.