FastPrepPlanning Production
Problems/Planning Production

Planning Production

Visa logoVisa● MediumNEW GRADOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

Source note: The screenshot cuts off the bottom of the Function Description, but the statement and example clearly show the two input arrays, worstCase and expected. FastPrep worked that out strictly from the visible details and stated rules. If we come across a fuller version later, we'll come back and update this.

You must plan production for a company that manufactures multiple products. For each product i:

  • worstCase[i] is the minimum cash that must be available before production begins.
  • expected[i] is the cost actually spent during production.

Determine the minimum amount of starting cash needed to manufacture all products. Products can be produced in any order, and after completing each product, the remaining cash can be used for subsequent products.

Function

plenProduction(worstCase: int[], expected: int[]) → long

Examples

Example 1

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

The optimal production order is 2, 1, 0:

  1. Start with 9 units of cash.
  2. Produce product 2: requires 7 units worst-case, spends 1 unit expected.
    • Remaining cash: 9 - 1 = 8 units
  3. Produce product 1: requires 5 units worst-case, spends 2 units expected.
    • Remaining cash: 8 - 2 = 6 units
  4. Produce product 0: requires 6 units worst-case, spends 4 units expected.
    • Remaining cash: 6 - 4 = 2 units

Therefore, the minimum starting amount is 9 units of cash.

More Visa Online Assessment questions

  • Count Prime Values in SubtreesOA · Seen Nov 2026
  • Lock CodeOA · Seen Nov 2026
  • Minimum-Sum Tree Fill with Unit StepsOA · Seen Nov 2026
  • Longest Non-Decreasing Substring After Pair SwapsOA · Seen Oct 2026
  • Count Attack Vectors by Divisor RangeOA · Seen Oct 2026
  • Minimum Operations to Reduce a Transaction LedgerOA · Seen Oct 2026
  • Count Valid Space-Delimited WordsOA · Seen Oct 2026
  • Earliest Common Meeting StartOA · Seen Oct 2026
  • Maximum Index-Weighted Sum with Disjoint SwapsOA · Seen Oct 2026
  • Maximum Equalized Substrings After One Adjacent SwapOA · Seen Sep 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
All Visa interview questionsSee Visa hiring insights
Saved
class Solution {
    public long plenProduction(int[] worstCase, int[] expected) {
      // write your code here
    }

}
Checking account…