FastPrepMinimum-Cost Solar Rooftop Allocation
Problems/Minimum-Cost Solar Rooftop Allocation

Minimum-Cost Solar Rooftop Allocation

Deloitte logoDeloitte● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Deloitte new grad online assessment. The report gives pooled extra energy, both production multipliers, and the goal of the lowest cost. It does not clearly state the rule of one rooftop per house or the numeric limits. We state those here. Our version is about 94% the same as the reported question.

A colony has n houses. House i requires requirements[i] units of energy. Energy produced by any rooftop enters a shared grid and may satisfy any house.

You may install at most one rooftop on each house:

  • A type-one rooftop costs typeOneCost and produces exactly requirements[i] units on house i.
  • A type-two rooftop costs typeTwoCost and produces exactly 2 * requirements[i] units on house i.
  • You may also leave a house without a rooftop.

Choose rooftops whose total production is at least the colony's total requirement. Return the minimum possible installation cost.

Function

minimumSolarCost(requirements: long[], typeOneCost: long, typeTwoCost: long) → long

Examples

Example 1

requirements = [4,2,1]typeOneCost = 5typeTwoCost = 8return = 8

The colony needs 7 units. One type-two rooftop on the house requiring 4 units produces 8 units at cost 8.

Example 2

requirements = [3,3,3]typeOneCost = 4typeTwoCost = 10return = 12

Three type-one rooftops produce exactly 9 units for cost 12, which is cheaper than every sufficient combination using type two.

Example 3

requirements = [10,1]typeOneCost = 100typeTwoCost = 3return = 3

A type-two rooftop on the first house produces 20 units, enough for the total requirement of 11, at cost 3.

Constraints

  • 1 <= requirements.length <= 100000
  • 1 <= requirements[i] <= 10^9
  • 1 <= typeOneCost, typeTwoCost <= 10^9
  • The answer fits in a signed 64-bit integer.

More Deloitte Online Assessment questions

  • Seventh Nearest PalindromeOA · Seen May 2026
  • Minimum Deletions for a Non-PalindromeOA · Seen Jul 2025
  • Pair Elements with Even SumsOA · Seen Jul 2025
  • Count Divisible PermutationsOA · Seen Jan 2025
  • Largest Element in an ArrayOA · Seen Nov 2024
  • Install Carbon FiltersOA · Seen Oct 2023
  • Longest Substring with Even OccurrencesOA · Seen Oct 2023
  • Maximum Sum RectangleOA · Seen Apr 2022
  • Annual Bank Balance with Monthly Card FeesOA · Seen Jan 2022
  • Count Battleships by SizeOA · Seen Jan 2022

Similar questions at other companies

  • Minimize Maximum Group DifferenceDRW · OADRW interview questions
  • Maximize Number of Produced CarsMicrosoft · OAMicrosoft interview questions
  • Aggressive CowsPeopleStrong · OAPeopleStrong interview questions
  • Spread Cows Across StallsExpedia · OAExpedia interview questions
  • Aggressive CowsAmazon · PHONE SCREEN
  • Maximize the Minimum Cone DistanceSumo Logic · PHONE SCREEN
  • Maximize Fish over Limited HoursByteDance · PHONE SCREENByteDance interview questions
  • Find Minimum TimeAlphaSense · OA
  • Find Minimum TimeBlackRock · OABlackRock interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions

Interview reports that mention this question

  • Deloitte New Grad Tech OA and Interview Questions: 14 Experiences
All Deloitte interview questionsSee Deloitte hiring insights
Saved
class Solution {
    public long minimumSolarCost(long[] requirements, long typeOneCost, long typeTwoCost) {
        // Write your solution here.
    }
}
Checking account…