BackmediumUncategorized uncategorized medium

Max Colonists With Resources Solution

Problem Statement

You are given three arrays representing the capacities of oxygen tanks, water containers, and food packets, along with the respective requirements of each colonist. Determine the maximum number of colonists that can be sustained with the available resources, given the arrays of oxygen capacities, water capacities, food capacities, oxygen requirements, water requirements, and food requirements.

Example 1
Input
{"oxygen":[3,4,5],"water":[2,3,4],"food":[1,2,3],"oxygenReq":[1,2],"waterReq":[1,1],"foodReq":[1,1]}
Output
2

Explanation: The maximum number of colonists that can be sustained is 2, as we can allocate resources to the first two colonists.

Constraints

  • 1 <= oxygen.length, water.length, food.length <= 10^5
  • 1 <= oxygenReq.length, waterReq.length, foodReq.length <= 10^5
  • 1 <= oxygen[i], water[i], food[i] <= 10^6
  • 1 <= oxygenReq[i], waterReq[i], foodReq[i] <= 10^6
  • The total amount of each resource is not more than 10^6
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