mediumArraysPattern: TOOL RETURNED ID

Filtered Array Indices Solution

Problem Statement

You are given a binary array `arr` of length `m` and an array `ids` of length `m`, where `arr[i]` represents the weight status and `ids[i]` represents the shipment ID. Find and return the IDs of shipments where the weight status is 1 and the shipment ID does not exist in a given array `processed_ids`.

Examples

Example 1:
Input:[{ id: 1, weightStatus: 1 }, { id: 2, weightStatus: 0 }, { id: 3, weightStatus: 1 }]
Output:[1, 3]
Explanation: Only shipments with weight status 1 are considered

Constraints

  • 1 <= m <= 10^5
  • 0 = exceeds weight limit, 1 = within weight limit
Time: O(m) Space: O(m)
Use a hash map to store the frequency of each shipment ID and then return the ones that appear only once.

Run, Test & Submit Code

Ready to practice this challenge? Launch our interactive compilation environment with compiler validation.

Solve on Interactive Workspace

Tested Solutions

No solution code is currently loaded.
Complete this code in the workspace editor.