Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Reverse a Number in an Array

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

Your question is Reverse a Number in an Array. 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

A Paytm QA data-quality check receives an array of integer transaction references. Reverse the digits of every number in the array, preserving the order of the elements. Implement the transformation using arithmetic operations rather than converting numbers to strings.

Negative numbers must remain negative, and leading zeroes created by reversal are discarded because the result is an integer. For example, reversing 1200 produces 21, while reversing -405 produces -504.

Formal Specification

Implement reverse_numbers(nums), where nums is a list of integers. Modify nums in place and return the same list after replacing each element with its digit-reversed value.

Constraints

  • 0 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9
  • Use arithmetic digit extraction, not string conversion
  • Return the modified input list

Function Signature

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