All practice tasks

Coding (Algo)

Minimum Capability Bundle

Dynamic programming · Hard

A deployment requires a fixed set of capabilities. Each available package provides a subset at a cost; buying overlapping packages is allowed.

Return the cheapest set of packages covering all required capabilities.

Input

Call

  • Implement solve(input) and return its result. Do not print from solve.

Input object

{ capabilities:integer, packages:{mask:integer,cost:integer}[] }

Input rules

  • Bits 0..capabilities-1 identify provided capabilities.

What each field means

  • capabilities — number of required capabilities, indexed from 0.
  • packages — a price cost and bitmask mask per package.
  • Bit i set in a mask means the package provides capability i; overlapping capabilities are allowed.

Output

Return value and rules

  • Return the minimum total cost of packages covering every required capability.
  • Each package may be chosen at most once. Return null if complete coverage is impossible.
  • Zero required capabilities cost 0. Return cost, not package indexes.

Constraints

  • 0 <= capabilities <= 16; 0 <= packages.length <= 200
  • 0 <= mask < 2^capabilities; cost in [0,1000000]; each package may be chosen at most once.

Examples

Example 1

{
  "capabilities": 3,
  "packages": [
    {
      "mask": 3,
      "cost": 4
    },
    {
      "mask": 6,
      "cost": 3
    },
    {
      "mask": 7,
      "cost": 9
    }
  ]
}

Returns

7

Example 2

{
  "capabilities": 0,
  "packages": []
}

Returns

0

Required complexity

O(packages × 2^capabilities) time and O(2^capabilities) space

What this task practices

Minimum Capability Bundle is a coding (algo) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as hard difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.