Reverse a String Manually
Updated
Problem statement
Given a string s, return its characters in reverse order. Implement the reversal manually without calling a built-in string or collection reversal operation.
Preserve every character, including spaces, punctuation, and letter case. The empty string reverses to the empty string.
Function
reverseString(s: String) → StringExamples
Example 1
s = "FastPrep"return = "perPtsaF"Reading the eight characters from right to left gives perPtsaF.
Example 2
s = "a b!"return = "!b a"The exclamation mark moves first and the space remains between b and a.
Constraints
0 <= s.length <= 2000.- Every character is printable ASCII (code 32 through 126).
More Newgen Software interview questions
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 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
- Reverse String In PlaceThe Walt Disney Company · OA · PHONE SCREENThe Walt Disney Company interview questions