Walmart Coding interview

In recent Walmart Assessment
Problem Statement

You are given n machine learning models.

For each model:

  • cost[i] represents the cost of the i-th model.
  • featureAvailability[i] is a binary string of length 2 describing which features the model supports:
    • "00" → supports neither Feature A nor Feature B
    • "01" → supports only Feature B
    • "10" → supports only Feature A
    • "11" → supports both Feature A and Feature B

A set of selected models is said to be k-capable if:

  • The number of selected models that support Feature A is at least k.
  • The number of selected models that support Feature B is at least k.

Note that a model with feature availability "11" contributes to both counts.

For every integer k from 1 to n, determine the minimum total cost required to select a k-capable set of models.

If it is impossible to form a k-capable set, return -1 for that value of k.

Comments (3)