I am trying to reverse the order of an Array in java.
What is the most efficient way to do so in O(n) with the least amount of memory used.
No need to answer with co
you can do it without needing a temp array
size - 1
, 1 and size - 2
etc)temp = a[i]; a[i] = a[end-i]; a[end-i] = temp;