Hackerrank OA Coding Challenge Capable Models
Interview Experience
Hello this was the question which was asked to me in a hackerrank test. I spent a lot of time in just understanding the question, I tried to give this to LLM but I don't think that was an optimized on
Full Details
Hello this was the question which was asked to me in a hackerrank test. I spent a lot of time in just understanding the question, I tried to give this to LLM but I don't think that was an optimized one or i could understand the solution properly. From the question I was able to understand being greedy on selection at each step while picking and the wording suggested as optimal that we need a greedy approach. But greedy by default should be fast like O(n).
Problem Name: Capable Models Given n machine learning models, each with an associated cost and feature compatibility: - cost[i] represents the cost of the ith model - featureAvailability[i] is a binary string indicating suitability for two distinct features: - "00": not equipped for either 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 if the number of models suitable for feature A and the number suitable for feature B are both greater than or equal to k. For each value of k from 1 to n, determine the minimum cost required to assemble a k-capable set of models.
Return an array of n integers, where the ith integer represents the minimum cost for an i-capable set. If no i-capable set exists, the ith integer should be -1.
Example n = 6 cost = [3, 6, 9, 1, 2, 5] featureAvailability = ["10", "01", "11", "01", "11", "10"] featureAvailability = ["10", "01", "11", "01", "11", "10"] | k | Optimal Model Indices | Feature A Models | Feature B Models | Total Cost | |---|-----------------------------|----------------------|----------------------|----------------------------| | 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, there will be no capable set. Hence, the answer is [2, 6, 15, 26, -1, -1].
Function Description Complete the function getMinimumCost in the editor with the following parameters:
int cost[n]
: the cost of machine learning models
string featureAvailability[n]
: the compatibility string of models indicating their suitability for two features Returns
int[n]
: the ith integer is the minimum cost of a set of i-capable models
Topics
More from Hackerrank
About Hackerrank Interview Reports
This question was reported by a candidate who interviewed at Hackerrank. LeakCode aggregates interview reports from 10+ sources, including 1Point3Acres, Glassdoor, LeetCode Discuss, Blind, Reddit, Indeed, and Nowcoder. Each report is translated where necessary, deduplicated against existing entries, and tagged by company, role, round type, and reporting date.
Use this question as one calibration data point, not a memorization target. Companies typically rotate their question pools every 2-4 months; the exact wording of a 2024 question may differ from what you encounter today. The underlying pattern, difficulty level, and follow-up depth at Hackerrank are the higher-signal extractions to take from this report.
For broader preparation context, the Hackerrank interview process typically includes a recruiter screen, one or two technical phone screens, and a 4-5 round on-site loop covering coding, system design (at L4+ levels), and behavioral. Reports tagged on LeakCode show the round-by-round distribution and typical difficulty calibration. To browse questions filtered by round type and seniority, use the company hub linked above.
How To Practice This Type of Question
Solve similar problems on LeetCode under timed conditions (25-35 minutes per medium difficulty). The goal is pattern recognition: recognize the underlying technique (sliding window, two-pointer, BFS, memoized recursion, etc.) within 60-90 seconds of reading. Strong candidates verbalize their hypothesis out loud before coding, then iterate based on feedback. Weak candidates dive into implementation immediately, lose time on the wrong approach, and run out of time for follow-ups.
Companies update their question pools every 2-4 months. The exact wording of any given question may have been retired by the time you interview. Focus your prep on the pattern, not the specific problem. The patterns that appear in Hackerrank reports consistently are the ones worth investing in; one-off niche problems are not.
During Your Hackerrank Round
Apply the standard interview round template: clarify requirements (2-3 minutes), state your approach out loud and confirm direction with the interviewer (3-5 minutes), code with narration (15-25 minutes), test with concrete examples including edge cases (5 minutes), discuss optimization or trade-offs if time permits (5 minutes). This template is universally accepted across FAANG and adjacent companies; deviating from it produces weaker interviewer feedback signal.
The single most predictive failure mode in Hackerrank reports tagged "no hire": not asking clarifying questions. Interviewers are explicitly trained to weight this. Strong candidates ask 3-5 clarifying questions even on problems that look obvious; weak candidates dive into code immediately. The clarifying-question check is often the first signal recorded in the interviewer's written notes.