Question: Write solution in java 8 , You are given a list of N transfers ( numbered from 0 to N - 1 ) between two
Write solution in java
You are given a list of N transfers numbered from to N between two banks: bank A and bank B The Kth transfer is described by two values: RKeither A or B representing the recipient the bank the transfer is sent to; VK denoting the value sent via the transfer. All transfers are completed in the order they appear on the list. The banks do not want to go into debt in other words, their account balance may not drop below What minimum initial acCOunt balance in each bank is necessary in order to Complete the transfers? Write a function: class Solution public int solutionString R int V; that given a string R and an array of integers V both of length N returns an array of two integers. The integers should represent the minimum initial account balances for banks A and B in the following order: bank A bank BResult array should be returned as an array of integers. Examples: Given R "BAABA" and V the function should return The bank accounts' balances after each transfer are shown in the following table: IA B initial balancetransfer from A to B transfer from B to A transfer from B to A transfer from A to Btransfer from B to AGiven R"ABAB"and V the function should return Given RB and V the function should return oWrite an efficient algorithm for the following assumptions: string R and array V are both of length N; N is an integer within the range ; each element of array V is an integer within the range ; string R is made only of the characters A andor B
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
