prices. You want to buy exactly two different items so that their total is **strictly less** than limit, while spending as much as possible.
Return the largest such total. If no pair fits under the limit, return -1.prices=[40, 15, 70, 25, 55], limit=80 → 70
The best pair is 55 and 15, for 70. No pair lands on 71–79: 55 + 25 = 80 is no longer below the limit.
prices=[30, 45], limit=60 → -1
The only pair costs 75, which is not below 60, so the answer is -1.
prices=[40, 15, 70, 25, 55], limit=80
70
Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.