Walmart Coding interview
Summary
I completed a coding assessment for Walmart that included a problem about selecting models to meet feature requirements.
Full Experience
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.
Interview Questions (1)
Minimum Cost k-Capable Model Selection
Given n models each with a cost and a binary string of length 2 indicating support for Feature A and Feature B, find for every k (1 ≤ k ≤ n) the minimum total cost of a subset of models such that at least k models support Feature A and at least k models support Feature B. Models with "11" count toward both features. Return -1 for a particular k if no subset satisfies the requirement.