Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Reverse an Array of Integers
00:00
5 left

Reverse an Array of Integers

EasyPython

Problem

Create a function to reverse an array of integers.

Implement reverse_array(nums) so it reverses nums in place and returns the same list. The input is a list of integers, and the output is the reversed list. Do not use Python's built-in reverse() method or slicing to perform the reversal.

Constraints

  • 0 <= len(nums) <= 10^5
  • Each element is an integer
  • The reversal must be performed in place
  • Do not use reverse() or slicing

Function Signature

def reverse_array(nums):
Interviewer

Your question is Reverse an Array of Integers. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.