So i have 2 arrays like this:
array1 = {1,2,3,4};
array2 = {353, 588, 213, 353};
The numbers in array1 corresponds to the respective indexes in array2, so from this it means: 1 of 353, 2 of 588, 3 of 213, 4 of 353. I want to be able to merge the duplicates in array 2 so the final one becomes:
array1 = {5,2,3};
array2 = {353,588,213};
I was thinking about looping through but I'm thinking it's inefficient so I was hoping someone would know the most efficient way to do this.
Thanks in advance!
Here's another example
array1 = {14,2,3,8,10,2,7,9};
array2 = {353, 588, 353, 213, 588, 213, 200, 353};
array1 = {26,12,10,7};
array2 = {353,588,213,200};