Using sorting will increase T.C., Try to do something with bits
Some hint for the question
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.