Company: Springworks_10dec
Difficulty: medium
Drone Delivery Problem Description A delivery drone has a strict weight limit K . You have a warehouse full of packages with varying weights. To optimize fuel, the drone must carry exactly two packages per trip. You want to choose two packages such that their combined weight is as large as possible without exceeding K . Return the maximum combined weight of such a pair. If no two packages can fit within the limit, return -1 . Function Description Complete the function max_weight_pair() . It takes the following 2 parameters and returns the answer: weights : a list of N integers, the weight of each package. k : an integer, the weight limit of the drone. Input Format For Custom Testing The first line contains two integers N and K , the number of packages and the weight limit. The second line contains N space-separated integers, the elements of weights . Output Format Print a single integer: the maximum combined weight of a valid pair of two distinct packages, or -1 if no such pair exists.