Question: IBM, Recently Asked Online Assessments in 01 Apr, 2025 | Machine Learning Models Cost | Distinct Project Cost Pairs | HackerRank Coding Assessment
0
Entering edit mode

Question 1: Machine Learning Models (k-capable sets)

Problem Statement: Given n machine learning models, each with an associated cost and feature compatibility. The cost of the ith} model is specified by the array element cost[i]. Additionally, each model is characterized by a binary string, featureAvailability[i], indicating its suitability for two distinct features:

  • If featureAvailability[i] = "00", it means the model is not equipped for either of the features.
  • If featureAvailability[i] = "01", the model is designed for feature A but not for feature B.
  • If featureAvailability[i] = "10", the model is designed for feature B but not for feature A.
  • If featureAvailability[i] = "11", the model is suitable for both features.

A set of models is considered k-capable if the number of models in that set suitable for feature A and the number of models suitable for feature B are both greater than or equal to k.

For each value of k, ranging from 1 to n, the goal is to determine the minimum cost required to assemble a set of k-capable machine learning models. The task is to return an array of n integers, where the ith integer denotes the minimum cost of acquiring a set of i-capable models. If there exists no feasible combination of i-capable models, the corresponding ith integer will be -1.

Example:

  • n = 6
  • cost = [3, 6, 9, 1, 2, 5]
  • featureAvailability = ["10", "01", "11", "01", "11", "10"]

 


Question 2: Count Distinct Pairs (Project Costs)

Problem Statement: A number of bids are received for a project. Determine the number of distinct pairs of project costs where their absolute difference is some target value. Two pairs are distinct if they differ in at least one value.

Example:

  • n = 3
  • projectCosts = [1, 3, 5]
  • target = 2

There are 2 pairs [1, 3], [3, 5] with the target difference target = 2. Therefore, 2 is returned.

Function Description: Complete the function countPairs with the following parameters:

  • int projectCosts[n]: array of integers
  • int target: the target difference

Return:

  • int: the number of distinct pairs in projectCosts with an absolute difference of target.
ADD COMMENTlink 1 day ago admin 1.9k

Login before adding your answer.

Similar Posts
Loading Similar Posts