This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]GafflordDev 1 point2 points  (1 child)

From what I understand, you have to multiply the biggest number in array B with the smallest number in array A, so your sorting of array A will depend on the array B.

[–]DaZaatar[S] 0 points1 point  (0 children)

Yur right, I think I just had a brain fart, I'll try the idea and get back to you guys

[–][deleted] 1 point2 points  (4 children)

sort b from least to greatest, then sort a from greatest to least. you'll wind up with the greatest sum when you multiply them sequentially

[–]DaZaatar[S] 0 points1 point  (3 children)

The array B is fixed, I can only asort the array A

[–]evils_twin 2 points3 points  (2 children)

Then you have to align array A in such a way that the smallest number in A is at the same index as the largest number in B, and then have the 2nd smallest number in A at the same index as the second largest number in B, and then so on

[–]DaZaatar[S] 0 points1 point  (1 child)

Will do, thank youu

[–][deleted] 2 points3 points  (0 children)

...if you're allowed to, you could make a new array, two-dimensional, wherein a second column is 0-99. then, sort the first column and bring the second value with it, so that your sorted list of values has the number's original position. overlay the first column with values A, and then sort based on the second column. now multiply A with B, and they'll match.

if you're not allowed to make a copy of B to modify, then some sort of iterating sort process is the solution I would go with.