DEV Community

Saranya R
Saranya R

Posted on

Reverse the array

Approach Explanation (o゜▽゜)o☆

  1. I used two pointers one at the start (i=0) and one at the end of the array (j = len(arr) - 1).
  2. I swapped the elements at those positions.
  3. I moved the pointers inward (start forward, end backward).
  4. I repeated the swaps until the pointers met in the middle.
  5. I ended up with the reversed array in place

Methods Used: ヽ( ̄▽ ̄)ノミ

  • Two pointer
  • Python built-in
  • Recursive

Top comments (0)