Skip to content

Instantly share code, notes, and snippets.

@Vaib215
Created September 24, 2022 14:40
Show Gist options
  • Save Vaib215/7df1f0f35bbd3ec340875f7870f56271 to your computer and use it in GitHub Desktop.
Save Vaib215/7df1f0f35bbd3ec340875f7870f56271 to your computer and use it in GitHub Desktop.
Time Complexity = O(n), Space Complexity = O(1)
public static void reverseArr(int arr[]){
int n = arr.length;
for(int i=0; i<n/2;i++){
int temp = arr[i];
arr[i] = arr[n-i-1];
arr[n-i-1] = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment