HardPro challengePythonJavaScriptTypeScript

Bulkhead Isolation

Node.jsResilienceConcurrency

Each "compartment" has independent capacity. solve(capacities, requests):

  • capacities: { name: max } map.
  • requests: [name, op] where op is 'enter' or 'leave'.

enter: if active < max, accept (active++) and push true; else push false.
leave: decrement active (floor 0), push null.

Sample tests

Test #1Filled
Input: [{"a":2},[["a","enter"],["a","enter"],["a","enter"]]]
Output: [true,true,false]
Test #2Leave then re-enter
Input: [{"a":1},[["a","enter"],["a","leave"],["a","enter"]]]
Output: [true,null,true]
Test #3Independent compartments
Input: [{"a":1,"b":1},[["a","enter"],["b","enter"]]]
Output: [true,true]
Test #4Zero capacity
Input: [{"a":0},[["a","enter"]]]
Output: [false]
Test #5Leave when empty
Input: [{"a":1},[["a","leave"]]]
Output: [null]