How can we swap 2 arrays in constant complexity or O(1)? Is there a way that we can do this? I have tried using pointers but it is giving an error
Moreover, this won't help because it is just interchanging the pointers but not the arrays:
#include <algorithm>
int AA[100], *A=AA, BB[100], *B=BB;
swap(A, B);
I have tried using vectors assignment operator as well but they have LINEAR complexity i.e. O(N) not constant. So, is there any way we can swap two arrays in O(1)? (by using pointers or something else)
I have tried searching on the internet and found a link to codeforces ( http://codeforces.com/blog/entry/11971 ) but this is not helping.