#36Medical Kit Assembly Planner
A futuristic medical logistics system manages a collection of supply capsules. Each capsule contains a small combination of medical resources represented by lowercase letters. A field medic sends a request for a specific sequence of medical resources. Your task is to determine the minimum number of capsules needed to fulfill the request.
You may open a capsule and take any of its resources. The resources can be rearranged freely, and each capsule type is available in unlimited quantity. A resource taken from one capsule cannot be reused. However, the same capsule type can be selected multiple times. Return the minimum number of capsules required to construct the complete medical request. If it is impossible to fulfill the request, return -1.
Real-World Applications" Emergency medical kit preparation Hospital supply allocation Automated pharmacy inventory planning
Examples
Example 1
Input: medCapsules = ["with","example","science"]
criticalRequest = "thehat"
Output: 3
Explanation: Three capsules are sufficient to obtain all required resources.
Example 2
Input: medCapsules = ["notice","possible"]
criticalRequest = "basicbasic"
Output: -1
Explanation: There are not enough required letters among the available capsule types to construct the request.
Example 3
Input: medCapsules = ["abc","def","ab"]
criticalRequest = "ab"
Output: 1
Explanation: The "abc" capsule alone provides both required resources.
Constraints
- 1 <= medCapsules.length <= 50
- 1 <= medCapsules[i].length <= 10
- 1 <= criticalRequest.length <= 15
- medCapsules[i] contains only lowercase English letters.
- criticalRequest contains only lowercase English letters.
- The number of capsule types is at most 50.
- Each capsule type is available in unlimited quantity.
