Here goes my code.
Unable to point out the error
@tanjuljain19 It can be solved easily by mapping the postions and then swapping the values. I dont know your approach but if you are using lower_bound() then you have to first sort the array
Don’t know how to update index of corresponding element in map