FastPrepNumber Digits Backward
Problems/Number Digits Backward

Number Digits Backward

DocuSign logoDocuSign● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report from May 2020 listed three questions from one hiring process. One was to reverse the order of a number's digits. The report does not say which step it came in.

It also does not say what to do with negative numbers, zeros at the end, or answers too big for a 32-bit integer. Here a negative number keeps its minus sign. Zeros at the end disappear (500 becomes 5). Any 32-bit input is allowed, and the answer is returned as a 64-bit integer. The first example is from the report. We wrote the others.

Our version is about 90% the same as the reported question.

You are given an integer n. Write its digits in the opposite order and return the number you get.

  • If n is negative, the answer is negative too. Reverse the digits and keep the minus sign in front.
  • Zeros at the end of n move to the front when reversed, and a number does not keep zeros in front. For example, 500 becomes 5.
  • n fits in a 32-bit integer, but the answer may not. Return it as a 64-bit integer.

Function

reverseDigits(n: int) → long

Examples

Example 1

n = 123return = 321

The digits 1, 2, 3 in reverse order are 3, 2, 1, so the answer is 321.

Example 2

n = -4050return = -504

Reverse the digits of 4050 to get 0, 5, 0, 4, which is the number 504. The zero in front is dropped. The minus sign stays, so the answer is -504.

Example 3

n = 1999999998return = 8999999991

The reversed digits give 8999999991. That is larger than the biggest 32-bit integer (2147483647), which is why the answer is a 64-bit integer.

Constraints

  • -2^31 <= n <= 2^31 - 1

More DocuSign Online Assessment questions

  • Max Sum With No Two Adjacent PicksOA · Seen Apr 2026
  • Max Sum With No Two Adjacent Picks on a CircleOA · Seen Apr 2026
  • Beautiful Number OrderingsOA · Seen Feb 2026
  • Grid Path With the Most ClearanceOA · Seen May 2025
  • Vehicle Mixes for a Wheel TotalOA · Seen May 2025
  • Count Sales Rung Up at the Wrong PriceOA · Seen Feb 2021
  • Most Disjoint Intervals From Starts and DurationsOA · Seen Feb 2021
  • Fewest Fountains to Water the GardenOA · Seen Feb 2021
  • Lowest Start That Keeps Running Totals PositiveOA · Seen Feb 2021
  • Fewest Student Groups Within a Level GapOA · Seen Nov 2020

Similar questions at other companies

  • Count Valid Square PairsAuxoAI · OA
  • Counting Cows by Their LegsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Server InvestmentRippling · OARippling interview questions
  • Basic Item DiscountsPalantir · OAPalantir interview questions
  • Identification Number Check DigitAbridge · OAAbridge interview questions
  • Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
  • Next Pascal Row CoefficientIntuit · OAIntuit interview questions
  • Digit-Sum Sequence Join PointOpenAI · OAOpenAI interview questions
  • Minimum Testers to Find the Poisoned BottleWalleye Capital · OA
  • Address on Same PageNVIDIA · OANVIDIA interview questions

Interview reports that mention this question

  • DocuSign SWE Intern Interviews: 27 Experiences (Part 2 of 2)

DocuSign interview experiences

  • DocuSign SWE Intern OA Questions: 53 Experiences (Part 1 of 2)
All DocuSign interview questionsSee DocuSign hiring insights
Saved
class Solution {
    public long reverseDigits(int n) {
        // Write your code here.
    }
}
Checking account…