03.Reverse an Array

EasyArrays

// Mission briefing

Given an array arr[] of integers, reverse the array. Reversing an array means rearranging the elements such that the first element becomes the last, the second element becomes the second last, and so on.

Implement a function that takes an array of integers and returns the reversed array.

// Constraints

  • 1 <= len(arr) <= 10^5
  • -10^9 <= arr[i] <= 10^9

Time limit: 1s ·  Memory limit: 256 MB

Hint 1

Consider using two pointers, one starting at the beginning and the other at the end of the array.

Hint 2

Swap the elements at these two pointers and move them towards each other.

Hint 3

Continue swapping until the pointers meet or cross each other.

solution.py