Given an integer of number and their priority, return the number with the greatest priority
Say
int[] number={0,1,3,4}
int[] priority={1,3,4,2} //All numbers are distinct
I would want to have the value 3(with priority 4 which is the largest), how could I achieve that easily and efficiently?
To answer your question directly without any suggestion about using other objects, try using
MAX()andIndexOf()since you have mentioned that all numbers inpriorityare distinct,