Reverse an ASCII String
Updated
Problem statement
Return text with its characters in reverse order.
For this exercise, assume the input contains printable ASCII characters. Reverse every character, including spaces and punctuation. An empty string stays empty.
Function
reverseText(text: String) → StringExamples
Example 1
text = "code"return = "edoc"The characters c, o, d, e become e, d, o, c.
Example 2
text = ""return = ""There are no characters to reorder.
Example 3
text = "ab cd!"return = "!dc ba"Reading the six characters from right to left gives !, d, c, space, b, a.
Constraints
0 <= text.length <= 50000.- Every character has an ASCII code from
32through126.
More Squarepoint Capital Phone Screen questions
- Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
- Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
- Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
- Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
- Parse, Normalize, and Combine PolynomialsPHONE SCREEN · Seen Aug 2026
- Sorted Insertion SnapshotsPHONE SCREEN · Seen Aug 2026
- Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
- Target Sum Across Two Sorted ArraysPHONE SCREEN · Seen Aug 2026
- Classify Heap Addresses from a Memory SnapshotPHONE SCREEN · Seen Nov 2025
- Fixed Worker Pool with a Shared QueuePHONE SCREEN · Seen Nov 2025
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
- Reverse a StringAmazon · PHONE SCREEN
- 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
- Reverse a StringPersistent Systems · PHONE SCREEN
- Minimum Changes for Palindromic BlocksCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
- Valid Palindrome IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions