Reported March 2026
FlexTradetwo pointers

Reverse a String

Reported by candidates from FlexTrade's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live FlexTrade OA. Under 2s to a working solution.
Founder's read

The FlexTrade OA reported in March 2026 hands you a plain array of characters and asks you to flip it. That's the whole question. Reverse a string, keep case, spaces, digits, and punctuation exactly as they are, and return empty for empty. It's a two-pointers problem at heart, and the only real decision is whether you swap in place or build a new string. Easy points if you stay calm, easy loss if you overthink it. If you blank on the syntax halfway through, StealthCoder runs invisibly during the live assessment and gives you a working solution so a trivial question doesn't sink you.

The problem

Given a string s, return a new string containing the same characters in reverse order.
Preserve character case, spaces, digits, and punctuation. An empty input returns an empty string.

Function
reverseString(s: String) → String

Examples
Example 1
s = "FastPrep"
return = "perPtsaF"
Reading FastPrep from right to left produces perPtsaF.
Example 2
s = "a b!"
return = "!b a"
The punctuation and space remain characters and move to their reversed positions.
Example 3
s = ""
return = ""
The reverse of the empty string is the empty string.

Constraints
0 <= s.length <= 200000
s contains only printable ASCII characters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that a string is just an indexable sequence of characters. Convert it to a char array, put one pointer at index 0 and another at the last index, swap, move both inward, and stop when they meet. That's O(n) time. Nothing needs special handling, because spaces and punctuation are ordinary characters. The common pitfalls are small. Some languages have immutable strings, so you can't swap in place without copying first. Repeated string concatenation in a loop can turn O(n) into O(n^2) with a length of 200000. Forgetting the empty string case is the other one, though a clean loop handles it for free. If you freeze on the language-specific details, StealthCoder is the hedge during the live OA. It reads the prompt and gives you the swap loop or the built-in reverse so you can submit and move on.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Reverse a String cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as reverse string. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass FlexTrade's OA.

FlexTrade reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Reverse a String FAQ

How hard is the FlexTrade Reverse a String question really?+

It's about as easy as coding questions get. The input is up to 200000 printable ASCII characters and the task is a single pass. If you can write a loop with two indices, you can solve it. The risk is rushing and making an off-by-one error.

What's the trick to solving it?+

Use two pointers, one at each end. Swap the characters they point to, move them toward the center, and stop when left is no longer less than right. Work on a mutable char array, then join it back into a string at the end.

Do I need to handle spaces and punctuation differently?+

No. The problem says case, spaces, digits, and punctuation are preserved and just move to their reversed positions. Example 2 shows 'a b!' becoming '!b a'. Treat every character the same and don't filter anything.

Will string concatenation be too slow here?+

It can be. Building the result by appending one character at a time in a loop may copy the string repeatedly in some languages, which hurts at length 200000. Use a char array, a list with a join, or a string builder to keep it linear.

How do I prepare in 48 hours for an OA like this?+

Write the two-pointer reverse from memory in your OA language, then test the empty string, a single character, and an even and odd length. Spend the rest of your time on harder patterns, since a question like this one is a warm-up and not the whole OA.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with FlexTrade.

OA at FlexTrade?
Invisible during screen share
Get it