Reverse Array
Niharika Pujari
Posted on August 24, 2020
Problem:
Write two functions reverseArray and reverseArrayInPlace. The first, reverseArray, takes an array as an argument and produces a new array that has the same elements in the inverse order. The second, reverseArrayInPlace, does what the reverse method does: it modifies the array given as argument in order to reverse its elements. Neither may use the standard reverse method.
Method 1: ReverseArray
Method 2: ReverseArrayInPlace
Which one is better? ReverseArrayInPlace : ReverseArray
ReverseArrayInPlace takes half the time and will replace two values at a time instead of looping the whole array and replacing the values one at a time.
💖 💪 🙅 🚩
Niharika Pujari
Posted on August 24, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.