Get Trucks for Items 🥥
Amazon Warehouse delivers different items in different trucks having varied capacities.
Given an array, trucks, of n integers that represents the capacities of different trucks,
and an array, items, of m integers that represent the weights of different items, for each
item, find the index of the smallest truck which has a capacity greater than the item's weight. If there are
multiple such trucks, choose the one with the minimum index.
If there is no truck that can carry the item, report -1 as the answer for the corresponding item.
Note: Assume that the trucks are indexed starting from 0. Also, multiple items can be mapped to the same truck. Each item is mapped independently, hence the trucks do not lose any capacity when a particular item is mapped to it.
Complete the function getTrucksForItems in the editor below.
getTrucksForItems has the following parameters:
int trucks[n]: the capacities of the trucksint items[m]: the weights of the items
1Example 1

2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.