BackmediumArrays Adobe PhonePe

Efficient Cargo Checker: Lost Shipments at Warehouse Solution

Problem Statement

Given a collection of shipments, find the shipment IDs that were within the weight limit for a specific vehicle but not processed by customs.

Example 1
Input
[{'id': 1, 'weight': 10, 'customs': true}, {'id': 2, 'weight': 8, 'customs': false}, {'id': 3, 'weight': 12, 'customs': true}, {'id': 4, 'weight': 8, 'customs': false}, {'id': 5, 'weight': 10, 'customs': false}] 1 10
Output
[4, 5]

Explanation: Step-by-step: 1. Iterate through the shipments array. 2. For each shipment, check if its weight is less than or equal to the weight limit of the first shipment (ID 1) and its customs status is false. 3. If both conditions are met, add its ID to the result array.

Example 2
Input
[{'id': 1, 'weight': 10, 'customs': true}, {'id': 2, 'weight': 8, 'customs': false}, {'id': 3, 'weight': 12, 'customs': true}, {'id': 4, 'weight': 8, 'customs': false}, {'id': 5, 'weight': 10, 'customs': false}] 1 10
Output
[4, 5]

Explanation: Step-by-step: 1. Iterate through the shipments array. 2. For each shipment, check if its weight is less than or equal to the weight limit of the first shipment (ID 1) and its customs status is false. 3. If both conditions are met, add its ID to the result array.

Constraints

  • 1 <= m <= 10^5
  • 0 = exceeds weight limit, 1 = within weight limit
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free