Algorithm · Square · Medium
You have a collection of books, each described by a price and a weight, along with a voucher worth a fixed amount. You want to spend the voucher on exactly two different books. Pick two books whose prices sum to exactly the voucher amount. Among all such pairs, choose the one whose total weight is as small as possible. Examples Example