Get Trucks for Items

Problem Overview

  • For each item weight, find the index of the smallest truck with capacity greater than that weight; if none, return -1.
  • Inputs/outputs: trucks[n] capacities and items[m] weights; output an array of indices; 0-based; multiple items can use the same truck; capacities do not decrease.
  • Constraints: 1 ≤ n,m ≤ 1e5; values up to 1e9.
  • Context: Warehouse logistics mapping items to trucks, independent per item.
  • From Amazon interviews; a coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: