Some hint for the question


Using sorting will increase T.C., Try to do something with bits


We can’t use sorting because the given vector is constant, if we want to sort then we have to compromise on memory.


Try Quick Sort for sorting. Or you can use inbuilt methods for sorting. Most of the languages use Quick Sort as inbuilt sorting algorithm.


It can be done in O(n). Do something will & or ^ bitwise operator.