Source Code:https://thecodingsimplified.com/rever...
Solution - 1: Using new array
We take a new array with size equal to given array
Now start iterating the element & keep on pushing from last in new array
Time Complexity: O(n), where n is number of values in array
Space Complexity: O(n)
Solution - 2: Using swapping
We take two variable start = 0 & end = n - 1
We swap the element present at start & end, increase the start++ & decrease the end--
we do this until start is less than end
Time Complexity: O(n), where n is number of values in array
Space Complexity: O(1)
Solution - 3: Using Library funtion
We do Collections.reverse(Arrays.asList(arr))
So basically we need to convert array to in list form & then reverse it
One point to note it take Object, so rather than premitive array, take Object Integer array
For more info, please see the video.
CHECK OUT CODING SIMPLIFIED
/ codingsimplified
★☆★ VIEW THE BLOG POST: ★☆★
http://thecodingsimplified.com
I started my YouTube channel, Coding Simplified, during Dec of 2015.
Since then, I've published over 500+ videos.
★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★
https://www.youtube.com/codingsimplif...
★☆★ Send us mail at: ★☆★
Email: [email protected]