Maximize Impression Value
Updated
Problem statement
You are given n ad impressions. Each impression has a value and a cost (its floor price), and you have a fixed budget.
Select a subset of the impressions whose total cost does not exceed budget. Return the maximum possible sum of their values.
Each impression may be selected at most once.
Function
maximizeImpressionValue(values: int[], costs: int[], budget: int) → longExamples
Example 1
values = [10,40,30,50]costs = [5,4,6,3]budget = 10return = 90Select the second and fourth impressions. Their total cost is 4 + 3 = 7, and their total value is 40 + 50 = 90. No other valid subset has a larger total value.
Constraints
1 <= values.length = costs.length <= 10001 <= budget <= 10^51 <= values[i] <= 10^91 <= costs[i] <= 10^5
More InMobi Online Assessment questions
- Validate a Bracket SequenceOA · Seen Oct 2026
- Count Substrings Matching with One Adjacent SwapOA · Seen Oct 2026
- Maximum Subarray with Start and End WindowsOA · Seen Oct 2026
- Minimum Service Cold StartsOA · Seen Oct 2026
- Range Maximum Subarray Sum QueriesOA · Seen Oct 2026
- Connected Components with Divisor ThresholdOA · Seen Aug 2026
- Supply Path OptimizationOA · Seen Aug 2026
- Delivery ServiceOA · Seen Jun 2026
- Shared InterestOA · Seen Jun 2026
- Temporal AnomaliesOA · Seen Jun 2026
Similar questions at other companies
- Card Game: Best First-Player ScoreShopify · OAShopify interview questions
- Maximum Game Score with Fixed Forward JumpsStripe · OAStripe interview questions
- 0/1 KnapsackConfluent · OAConfluent interview questions
- Minimum Cost to Tile a Strip with Widths 1, 2, and 3Infosys · OAInfosys interview questions
- Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
- Maximum Subarray SumStraive · OA
- Longest Increasing Price SubsequenceOpenAI · OAOpenAI interview questions
- Lowest-Cost Shirt Color ScheduleElevenLabs · OAElevenLabs interview questions
- Maximum Game Board ScoreJP Morgan Chase · OAJP Morgan Chase interview questions
- API Bandwidth AllocationArista Networks · OAArista Networks interview questions