Question
JAVA Array and Loop Question. There are two arrays, one holds time and one holds amount, each corresponding to each other. arrA= [ 0, 2,
JAVA Array and Loop Question.
There are two arrays, one holds time and one holds amount, each corresponding to each other.
arrA= [ 0, 2, 3, 0, 2]
arrB = [500, 100, 400, 650, 50]
From these I must find the maximum sum of array B with correspondence of arrA being the urgency #.
So for example from the arrays above: from arrA there are two 0s. I must pick the one with the highest amount, in this case 650. Then the next is there are two 2s, and pick the max amount which is 100, and 3 is just one. From this my max sum should be 1150. What would be the loop behind this algorithm, tried to do it but got very confused.
EXTRA: with each loop iteration, arrA elements must decrease by 1. so for i =1, arrA = [ 0, 1, 2, 1, 0], if i=2 arrA = [0, 0, 1, 0, 0], etc...
It would be nice if you could help me with this but just showing the above one is fine too. Thank you, will give thumbs up for correct code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started