Reported September 2026
Rampstring

Convert Snake Case Variables to Camel Case

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

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

Ramp reported this one in September 2026, and it's mostly string handling with a couple of edge cases. The problem reduces to one question: which underscores are internal and which are padding? Split on spaces, keep the leading and trailing underscores, and capitalize the letter after every internal underscore. That's the whole thing. It looks like a warm-up, but the underscore edge cases are where people lose points. If you blank on the boundary logic during the live OA, StealthCoder is the safety net running invisibly on your screen. Otherwise, read on and you can write this in ten minutes.

The problem

Given a string text containing space-separated variable names written in snake_case, convert every variable name to camelCase and return the resulting string.
For each variable name:
Preserve every leading and trailing underscore.
Remove each underscore between lowercase words and capitalize the first letter of the following word.
Leave a variable name with no internal underscore unchanged.
Keep the variable names in their original order and keep the single spaces between them.

Function
toCamelCase(text: String) → String

Examples
Example 1
text = "__variable_one__ _variable_two variable_three"
return = "__variableOne__ _variableTwo variableThree"
The leading and trailing underscores stay in place. The internal underscores are removed, and the letters o and t that follow them become uppercase.
Example 2
text = "foo_bar __hello_world_ plain"
return = "fooBar __helloWorld_ plain"
foo_bar becomes fooBar, __hello_world_ becomes __helloWorld_, and plain is unchanged.

Constraints
1 <= text.length <= 10^5.
text contains lowercase English letters, underscores, and single spaces.
Variable names are separated by exactly one space, with no leading or trailing space.
Each variable name contains at least one letter.
After removing its leading and trailing underscores, each variable name contains one or more non-empty lowercase words separated by single underscores.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is separating the padding from the core. For each token, count leading underscores, count trailing underscores, and treat the middle as the real name. Inside the middle, walk the characters. When you hit an underscore, skip it and uppercase the next letter. Then reattach the padding. The constraints help you: the middle only has single underscores between non-empty lowercase words, so there are no double underscores to worry about. The common pitfall is converting every underscore blindly, which eats the leading and trailing ones and fails both examples. Another is using repeated string concatenation in a loop. With text up to 10^5 characters, build a list of characters and join once. Total time is O(n). If the boundary logic slips under pressure, StealthCoder can give you a clean reference solution on the live OA, but the logic is simple enough to write cold.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Convert Snake Case Variables to Camel Case 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Ramp reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Convert Snake Case Variables to Camel Case FAQ

How hard is the Ramp snake case to camel case question really?+

Easy on algorithm, medium on care. There's no data structure to pick. The score depends on handling leading and trailing underscores correctly and not mangling single-word names. If you test both examples by hand, you'll catch the usual mistakes before submitting.

What's the trick to solving it?+

Split the text on spaces. For each word, peel off the leading and trailing underscores, convert only the middle part, then stick the padding back on. In the middle, drop each underscore and uppercase the next character. Everything else stays as is.

Do I need regex for this?+

No. A regex can work, but a manual scan is safer because you control exactly which underscores count as internal. A single pass with an index and a capitalize-next flag is easy to reason about and runs in linear time.

What edge cases should I test?+

Test a name that is only padding around one word like _a_, a name with no internal underscore like plain, and trailing underscore after a multiword name like hello_world_. Also test a single-token input with no spaces, since splitting should still return one item.

How do I prepare for this in 48 hours?+

Write this once from scratch, then do two or three other string-parsing problems that need index tracking. Practice building output in a list and joining it. Focus on reading the constraints closely, since they remove most of the ugly cases for you.

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

OA at Ramp?
Invisible during screen share
Get it