BackhardHeap and Priority Queue Uber

Minimize Equipment Collection Trips Solution

Problem Statement

You are given an array of pairs of integers, where each pair represents the weight and priority of an equipment. Determine the order in which the equipment should be collected to minimize the number of trips, given a capacity constraint.

Example 1
Input
[[3, 1], [2, 2], [1, 3]], 4
Output
2

Explanation: Collect equipment with priority 3 first, then collect the remaining equipment.

Example 2
Input
[[1, 1], [1, 1], [1, 1]], 2
Output
2

Explanation: Collect two equipment in the first trip and the remaining one in the second trip.

Constraints

  • 1 <= equipment.length <= 10^5
  • 1 <= weight, priority <= 10^5
  • 1 <= capacity <= 10^5
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