BackmediumArrays arrays medium

Tank Water Allocation Solution

Problem Statement

Given two arrays, `capacities` representing the capacities of water tanks and `requirements` representing the water requirements, calculate the total amount of water available in a subset of tanks and determine if it can fulfill the requirements of a particular sector.

Example 1
Input
[10, 20, 30], [15, 25, 35]
Output
undefined

Explanation: The total water in the first two tanks (10 + 20 = 30) can fulfill the first requirement of 15, but not the second requirement of 25, so the output should be [true, false, false]

Constraints

  • 1 <= capacities.length <= 100
  • 1 <= requirements.length <= 100
  • 1 <= capacities[i] <= 1000
  • 1 <= requirements[i] <= 1000
  • The sum of all capacities does not exceed 10000
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