Reported July 2026
IndiaMARTtwo pointers

Reverse a String

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

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

The fastest way to fumble the IndiaMART Reverse a String question, reported in July 2026, is to overthink it or to mutate something you can't mutate. It's a warm-up. Two pointers, swap from both ends, done. But easy problems punish sloppy habits: wrong return type, off-by-one on the loop, forgetting that strings are immutable in some languages. Case and non-letter characters stay exactly as they are, so no filtering, no normalizing. If you blank on the syntax while the clock runs, StealthCoder sits invisibly on your screen as a safety net. Most people won't need it here, but a calm second opinion beats a silent panic.

The problem

Given a string s, return a new string containing the same characters in reverse order.
Character case and all non-letter characters must be preserved.

Function
reverseString(s: String) → String

Examples
Example 1
s = "FastPrep"
return = "perPtsaF"
Reading the input from right to left produces perPtsaF.
Example 2
s = "hello"
return = "olleh"

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that there's no trick. Convert the string to a character array, put one pointer at index 0 and one at the last index, swap, move inward, stop when they cross. That's O(n) time and O(n) space because of the array copy. The common pitfall is looping to the full length instead of half, which swaps everything back and returns the original string. Another is trying to assign to s[i] in a language where strings are immutable. Also don't strip spaces or punctuation. The statement says all non-letter characters are preserved, so "FastPrep" becomes "perPtsaF" with case untouched. Empty and single-character strings should fall through cleanly. If you freeze on language-specific syntax during the live OA, StealthCoder can hand you the clean version so you can verify it against the examples and move on.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

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 IndiaMART's OA.

IndiaMART reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Reverse a String FAQ

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

It's about as easy as OA problems get. You're reversing characters with no filtering, no case changes, no special rules. The risk isn't the algorithm, it's careless mistakes like wrong loop bounds or returning the wrong type. Solve it in a few minutes and save your energy for harder questions.

What's the trick to solving it?+

Use two pointers, one at each end, and swap while left is less than right. Stop when they meet. That reverses in place on a character array. Built-in reverse functions also work, but the two-pointer version shows you understand what's happening if the interviewer asks.

Do I need to handle spaces, punctuation, or uppercase letters differently?+

No. The problem says case and all non-letter characters are preserved, which just means treat every character the same. Reverse positions, don't touch the characters. Example: "FastPrep" becomes "perPtsaF" with the capital letters moving with their characters.

What edge cases should I test before submitting?+

Test an empty string, a single character, an even-length string, and an odd-length string. Also run both provided examples, "FastPrep" and "hello". Odd length checks that the middle character stays put, and even length checks that your loop stops at the right spot.

How should I prepare in 48 hours for this kind of question?+

Write the two-pointer swap from memory in your chosen language until it's automatic, including how to convert a string to a mutable array. Then spend the rest of your time on medium-level array and string problems, since an easy warm-up like this usually isn't the whole assessment.

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

OA at IndiaMART?
Invisible during screen share
Get it