Minimum Cost K-Capable Models
Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Microsoft OA question, reported in June 2026, is treating it as one greedy pass over sorted costs. It isn't. You need a k-capable set for every k from 1 to n, and the "11" models can count toward both features at once. Split the models into four buckets by their feature string, sort each by cost, and build the answer from prefix sums. If you blank on the bucket logic mid-assessment, StealthCoder runs invisibly on your desktop and gives you the solution in real time. Know the shape before you open the invite.
The problem
Given n machine learning models, each model has an associated cost and feature compatibility: cost[i] is the cost of the i-th model. featureAvailability[i] is a two-character binary string:"00": suitable for neither feature. "01": suitable for feature A but not feature B. "10": suitable for feature B but not feature A. "11": suitable for both features. A set of models is k-capable when the number of selected models suitable for feature A and the number suitable for feature B are both at least k. For every k from 1 through n, determine the minimum cost required to assemble a k-capable set. Return an array of n integers, where the value at index k - 1 is that minimum cost. If no k-capable set exists, return -1 for that position. Function minimumKCapableModelCosts(cost: int[], featureAvailability: String[]) → int[] Examples Example 1 cost = [3, 6, 9, 1, 2, 5] featureAvailability = ["10", "01", "11", "01", "11", "10"] return = [2, 6, 15, 26, -1, -1] The model indices in the source table are 1-based. Minimum-cost capable sets for the examplekOptimal setFeature 1 compatibleFeature 2 compatibleCost 1[5][5][5]2 2[1, 4, 5][1, 5][4, 5]3 + 1 + 2 = 6 3[1, 3, 4, 5][1, 3, 5][3, 4, 5]3 + 9 + 1 + 2 = 15 4[1, 2, 3, 4, 5, 6][1, 3, 5, 6][2, 3, 4, 5]3 + 6 + 9 + 1 + 2 + 5 = 26 For k >= 5, no capable set exists. Therefore, the answer is [2, 6, 15, 26, -1, -1].
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is bucketing. Sort the "11", "10", "01" and "00" groups by cost and build prefix sums for each. For a given k, pick j models from "11", then you need k-j from "10" and k-j from "01". Those are the cheapest k-j of each bucket. Try every valid j and take the minimum total. The "00" models never help, because they satisfy neither feature. Pitfall one: forgetting that each k is its own problem, so a set that works for k=2 isn't automatically optimal for k=3. Pitfall two: skipping the feasibility check. If j plus the bucket sizes can't reach k for both features, return -1. Naive per-k enumeration is O(n^2) overall, which is fine for modest n. A tighter version uses a two-pointer or greedy merge of the remaining models. StealthCoder is the hedge if the loop bounds trip you up live.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Minimum Cost K-Capable Models cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Microsoft's OA.
Microsoft reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Cost K-Capable Models FAQ
What's the trick in Minimum Cost K-Capable Models?+
Bucket models by feature string, sort each bucket, and build prefix sums. For each k, loop over how many "11" models you take, then fill the rest from the "10" and "01" buckets. Take the minimum cost across all valid splits.
How hard is this Microsoft OA question really?+
Medium. The idea is simple once you see the buckets, but the per-k loop and the -1 cases cause bugs. Most failed attempts miss that "11" models serve both features, or they reuse one greedy choice across every k.
Do the "00" models matter?+
No. They satisfy neither feature, so including them only adds cost. Ignore them. They only matter for the array length, since k still runs from 1 to n and many large k values return -1.
When do I return -1 for a k?+
When you can't get at least k models for feature A and at least k for feature B. Count the "11" models plus the "10" models for one feature, and the "11" plus "01" for the other. If either total is below k, that position is -1.
How do I prepare for this in 48 hours?+
Write the bucket and prefix-sum solution from scratch twice. Test it on the example, where the answer is [2, 6, 15, 26, -1, -1]. Then try edge cases: all "11", no "11", and one feature missing entirely. Focus on the loop bounds, not memorizing code.