Reverse the Characters of a Text
Updated
Problem statement
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) → StringExamples
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 <= 5000textcontains 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