FastPrepMinimum Initial Balances for Ordered Bank Transfers
Problems/Minimum Initial Balances for Ordered Bank Transfers

Minimum Initial Balances for Ordered Bank Transfers

Marshall Wace logoMarshall Wace● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Marshall Wace new grad online assessment. The report gives the rule for the receiving bank, the order of the transfers, three examples, a trace of the balances and all the input limits. We reworded the task in our own way. Our version is about 99% the same as the reported question.

Two banks, A and B, execute transfers in the listed order. Transfer i sends V[i] from one bank to the receiving bank named by R[i].

Both banks must start with nonnegative balances, and neither balance may become negative after any transfer. Return the minimum necessary starting balances as an integer array in the order [A, B]. A bank named in R receives that transfer; the other bank sends it.

Function

solution(R: String, V: int[]) → int[]

Examples

Example 1

R = "BAABA"V = [2,4,1,1,2]return = [2,4]

The balances in [A,B] order are [2,4] initially, then [0,6], [4,2], [5,1], [4,2] and [6,0]. A smaller initial balance for either bank would make some transfer impossible.

Example 2

R = "ABAB"V = [10,5,10,15]return = [0,15]

Starting from [0,15] keeps both banks nonnegative through all four transfers.

Example 3

R = "B"V = [100]return = [100,0]

Bank A must send 100 to B, so A starts with 100 and B can start with zero.

Constraints

  • 1 <= R.length = V.length <= 100000.
  • R contains only A and B.
  • 1 <= V[i] <= 10000.

More Marshall Wace Online Assessment questions

  • Count Letters with Ordered Lowercase and Uppercase OccurrencesOA · Seen Oct 2025
  • Maximum Trailing Zeros on a Path with at Most One TurnOA · Seen Oct 2025
  • Shortest Subarray Covering an Integer RangeOA · Seen Oct 2025
  • Maximum Events in a 60-Second WindowOA · Seen Aug 2025
  • Successful Logins from Multiple CountriesOA · Seen Aug 2025
  • Maximize Remaining Item Types After Clearing Consecutive ShelvesOA · Seen Nov 2024
  • Shortest String After Erasing Equal PairsOA · Seen Nov 2024
  • Count Distinct Tags in a Fixed-Radius Circle (Practice Reconstruction)OA · Seen Apr 2024
  • Generate Unique Company Email AddressesOA · Seen Apr 2024
  • Reconstruct a Two-Row Binary MatrixOA · Seen Apr 2024

Similar questions at other companies

  • Minimum Positive Starting ValueBooking.com · OA
  • Array Interval SumsHeadlands Technologies · OAHeadlands Technologies interview questions
  • Minimum AmountBelvedere Trading · OA
  • Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
  • Range Sum QueriesIntuit · OAIntuit interview questions
  • Shortest Distance on a Circular Bus RouteAmazon · OA
  • Count Sortable SplitsGoogle · OAGoogle interview questions
  • Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
  • Range Negation UpdatesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Threshold AlertsGoldman Sachs · OAGoldman Sachs interview questions

Interview reports that mention this question

  • Marshall Wace Coding Tests: 11 Experiences (Part 2 of 3)
  • Marshall Wace Quant and Coding OA: 19 Experiences (Part 1 of 3)

Marshall Wace interview experiences

  • Marshall Wace Older Quant Tests: 5 Experiences (Part 3 of 3)
All Marshall Wace interview questionsSee Marshall Wace hiring insights
Saved
class Solution {
    public int[] solution(String R, int[] V) {
        // Write your solution here.
    }
}
Checking account…