BackmediumUncategorized uncategorized medium

Maximize Supply Allocation Solution

Problem Statement

Given two arrays of integers, `supplies` and `demands`, where `supplies[i]` represents the supply at the i-th source and `demands[j]` represents the demand at the j-th sink, determine the maximum total supply that can be allocated to meet the demands while minimizing excess supply.

Example 1
Input
{"warehouseCapacities":[10,20,30],"campDemands":[15,25]}
Output
40

Explanation: The maximum supply is allocated by providing 10 units from the first warehouse, 20 units from the second warehouse, and 10 units from the third warehouse to meet the demands of 15 and 25 units.

Constraints

  • 1 <= supplies.length <= 1000
  • 1 <= demands.length <= 1000
  • 1 <= supplies[i] <= 10^4
  • 1 <= demands[j] <= 10^4
  • The total supply is greater than or equal to the total demand
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