Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Reverse Array In Place

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Reverse Array In Place. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Given an array arr of integers, reverse the array in place without using built-in language functions such as reverse() or slicing. Return the reversed array after modifying it by swapping elements from both ends toward the center.

Constraints

  • 0 <= len(arr) <= 10^5
  • -10^9 <= arr[i] <= 10^9
  • Do not use built-in array reversal functions or slicing shortcuts

Function Signature

def reverse_array(arr):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output