What's the complexity of swapping two rows in 2D vector and in 2D array, I tested the time complexity on both it seems that in vectors swapping is almost O(1)
but in arrays works slower, so what's the indeed complexity, why are different?
in arrays (very slow):
int arr[N][N];
// input the array elements
while (q--) { // number of queires
int x, y;
scanf("%d %d", &x, &y);
swap(arr[x], arr[y]);
}
in vectors the same code above but instead of using int arr[N][N]
I use vector<<vector>>