swap vector elements code example
Example 1: swap two elements of a vector
std::iter_swap(arr.begin()+pos1,arr.begin()+pos2);
Example 2: swap vector c++
vector1.swap<vector2>;
//time complexity: O(1)
std::iter_swap(arr.begin()+pos1,arr.begin()+pos2);
vector1.swap<vector2>;
//time complexity: O(1)