Unable to point out the error


Here goes my code.

@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

https://ide.codingblocks.com/s/228837 Unable to resolve the error

Don’t know how to update index of corresponding element in map

@tanjuljain19 just start from the largest element . And yes update in maps using normal updation.

https://ide.codingblocks.com/s/231944 showing error while displaying answer