FastPrepPlanning Production
Problems/Planning Production

Planning Production

Atlassian logoAtlassian● MediumOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Acme Corp has a number of products that need to be manufactured. However, careful planning must take place before production begins. For each product there is a worst-case cost and an expected cost. Before starting a project, Acme must have at least enough cash on hand to pay the worst-case cost for each product. If every product is produced at expected cost, determine the minimum beginning cash requirement to get all products produced. Products can be produced in any order.

Function

planProduction(worstCase: int[], expected: int[]) → int

Complete the function planProduction in the editor.

planProduction has the following parameter(s):

  1. worstCase[worstCase[0],...worstCase[n-1]]: an array of n integers representing the minimum cash-on-hand to produce the ith product
  2. expected[expected[0],...expected[n-1]]: an array of n integers, representing the expected cost to produce the ith product.

Returns int: the minimum beginning cash requirement to get all products produced

Examples

Example 1

worstCase = [6, 5, 7]expected = [4, 2, 1]return = 9

For this case, the optimal order of production is product 2, 1, and 0. Starting with 9 units of cash on hand, they can begin production of product 2 because cash on hand (9 units) ≥ worstCase (7 units). After finishing product 2, they will have 9 - 1 = 8 units of cash on hand. They can then move to product 1 as cash on hand (8 units) ≥ worstCase (5 units). When product 1 is complete, they will have 8 - 2 = 6 units of cash on hand which is enough to start product 0 as cash on hand (6 units) = worstCase (6 units). The minimum amount of cash on hand that will work is 6 - 4 = 2 units. The answer is 9.

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ worstCase[i] ≤ 10^5
  • 1 ≤ expected[i] ≤ 10^5
  • It is guaranteed that expected[i] ≤ worstCase[i] for every i (0 ≤ i < n).

More Atlassian interview questions

  • Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Deterministic Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
  • Generate Word Guess FeedbackONSITE INTERVIEW · Seen Oct 2026
  • Bounded Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
  • Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
  • Word Guess Feedback ColorsONSITE INTERVIEW · Seen Oct 2026
  • Longest Consistent Activity StreakPHONE SCREEN · Seen Sep 2026
  • Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
  • Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026

Similar questions at other companies

  • Hiking Club Fastest PaceInfosys · OAInfosys interview questions
  • Find Minimum TimeAlphaSense · OA
  • Find Minimum TimeBlackRock · OABlackRock interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Minimum Cost of Every K-Capable Model SetTikTok · OATikTok interview questions
  • Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Maximize Minimum Deployment DifficultyJP Morgan Chase · OAJP Morgan Chase interview questions

Atlassian interview experiences

  • Atlassian MLE Phone Screen: Model Deployment Design: 1 Experience
  • Atlassian Coding Screens and Karat: 3 Experiences (Part 2 of 2)
  • Atlassian Full Stack Interviews: 11 Experiences (Part 1 of 2)
All Atlassian interview questionsSee Atlassian hiring insights
Saved
class Solution {
    public int planProduction(int[] worstCase, int[] expected) {
      // write your code here
    }

}
Checking account…