Array reduction operator question

In reply to mannat:

You need to clarify a few things. Does it matter which array might have more elements? How are repeated values handled? For example what would you expect the result of this to be?

arr = {9,1,8,4,6,5,5,5};
q = {9, 1, 8, 3, 4, 4, 5};