FastPrepReverse the Characters of a Text
Problems/Reverse the Characters of a Text

Reverse the Characters of a Text

DocuSign logoDocuSign● EasyINTERNPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two reports mention this task. One, from September 2018, describes a 30-minute phone screen that turned to reversing a string. It was solved by building a new string one character at a time. The other, from April 2022, says it came up in two of the candidate's interviews, with follow-ups about not using another data structure and about time and space cost.

The reports give no limits or examples. Here the text has 0 to 5,000 characters (letters, digits, spaces and a few punctuation marks), and you return the reversed text. The editorial covers the follow-up about using no extra structure. A palindrome check asked next is a separate problem. We wrote the examples.

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

Write the characters of text from right to left and return the result. If text has n characters, position k of the answer holds character n - 1 - k of text.

Whatever a character is, a letter, digit, space or comma, it lands in its mirrored position. Letter case does not change. When n is odd, the middle character stays where it is.

Function

reverseText(text: String) → String

Examples

Example 1

text = "stamp"return = "pmats"

Read "stamp" from the last letter to the first: p, m, a, t, s. The answer is "pmats".

Example 2

text = "Sign here, 2x!"return = "!x2 ,ereh ngiS"

Every character moves, including the space, the comma, the digit and the exclamation mark. The answer is "!x2 ,ereh ngiS".

Example 3

text = "level up"return = "pu level"

The 8 characters in reverse order are p, u, space, l, e, v, e, l. The answer is "pu level".

Constraints

  • 0 <= text.length <= 5000
  • text contains only English letters, digits, spaces and the characters . , ! ? -

More DocuSign Onsite Interview questions

  • Count Binary SubstringsONSITE INTERVIEW · Seen Sep 2026
  • Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Compress Consecutive Integer RangesONSITE INTERVIEW · Seen Aug 2026
  • JSON Schema Object ValidatorONSITE INTERVIEW · Seen Aug 2026
  • Most Transactions Kept Without Going NegativeONSITE INTERVIEW · Seen May 2025
  • Three-Part Splits With a Light MiddleONSITE INTERVIEW · Seen May 2025
  • Combine Two Sorted Lists Into OneONSITE INTERVIEW · Seen Apr 2022
  • Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
  • Paired Words That Share a SubstringONSITE INTERVIEW · Seen Apr 2022
  • Reverse the Order of a Linked ListONSITE INTERVIEW · Seen Feb 2020

Similar questions at other companies

  • Check if a String Is a PalindromeCisco · PHONE SCREENCisco interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Reverse a StringAmazon · PHONE SCREEN
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Reverse a String ManuallyNewgen Software · PHONE SCREEN
  • Reverse a String with Two PointersSnowflake · PHONE SCREENSnowflake interview questions
  • Palindrome with One DeletionWhatNot · PHONE SCREENWhatNot interview questions
  • Valid Word AbbreviationMeta · PHONE SCREENMeta 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 String reverseText(String text) {
        // Write your code here.
    }
}
Checking account…