Find Minimum Trips π
There were a large number of orders placed on Amazon Prime Day. The orders are packed and are at the warehouse ready to be delivered. The delivery agent needs to deliver them in as few trips as possible.
In a single trip, the delivery agent can choose packages following either of two rules:
Determine the minimum number of trips required to deliver the packages. If it is not possible to deliver all of them, return -1.
Complete the function findMinTrips in the editor.
findMinTrips has the following parameter:
int packageweight[n]: the weights of each package
Returns
int: the minimum number of trips required or -1 if it is not possible to deliver them all
π π π π° Credit to Jane π° π π π
1Example 1

2Example 2
3Example 3

Constraints
Limits and guarantees your solution can rely on.
1 β€ n β€ 10551 β€ packageweight[i] β€ 109