Find Minimum Cost
Updated
Problem statement
You are given a list of houses, such that A[k] corresponds to the amount of energy needed for house k. You will be installing two types of solar panels:
- Type 1: A solar panel which provides
A[k]amount of power for priceX. - Type 2: A solar panel which provides
2 * A[k]amount of power for priceY.
Your goal is to find the minimum cost such that all houses are provided with at least their required amount of power.
Note: The power distributed from Y is not sequential, as you only focus on providing at least the net amount of energy of all the houses.
Function
findMinimumCost(A: int[], X: int, Y: int) → intExamples
Example 1
A = [4, 3, 5, 2]X = 2Y = 5return = 7Assign solar panel type Y to A[2], which will cover A[1] and A[3], and then assign solar panel type X to A[0]. Thus the minimum cost is 5 + 2 = 7.
Constraints
🥭🥭
More Microsoft interview questions
- Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
- Authentication SystemOA · Seen Nov 2026
- Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
- Maximum String OperationsOA · Seen Nov 2026
- Minimum Cost to Process Priority TasksOA · Seen Nov 2026
- Most Visited Sprint MarkerOA · Seen Nov 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
- Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
- Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
- Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
- Task Scheduler with CooldownGoDaddy · OA
- Minimize Adjacent Squared-Difference Cost with One InsertionMcKinsey & Company · OAMcKinsey & Company interview questions
- Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
- Minimum Values with Even Powers of TwoVisa · OAVisa interview questions
- Minimum Halvings for Alternating ParityIBM · OAIBM interview questions
- Resource AllocationMaven Securities · OAMaven Securities interview questions
- Return Exact Cash Register ChangeBank of America · OABank of America interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
Microsoft interview experiences
- Microsoft OA Questions, October 2026: 4 Experiences
- Microsoft Experienced SWE Phone Screen: 1 Experience
- Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
- Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
- Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
- Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)