Reported July 2026
Googlestring

Convert Snake Case to Camel Case

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

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

The mistake that sinks a first attempt on this Google OA, reported in July 2026, is capitalizing the wrong character or leaving an underscore behind. The task is small: turn foo_bar into fooBar. It's a string problem with one pass and no tricks, which is exactly why people rush it and fumble the edge. Constraints say no leading, trailing, or double underscores, so you can stay simple. If you blank under the clock, StealthCoder runs invisibly on your desktop during the live OA and hands you a working solution as a safety net. Read the constraints first, then write it clean.

The problem

Given a valid snake_case string, convert it to camelCase. Remove each underscore and capitalize the first letter of the following word.

Function
toCamelCase(s: String) → String

Examples
Example 1
s = "foo_bar"
return = "fooBar"

Constraints
The input is valid snake_case.
The input does not begin or end with an underscore.
The input does not contain two consecutive underscores.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is a single left-to-right scan with a flag. Walk the string. When you hit an underscore, skip it and set a flag. On the next character, uppercase it if the flag is set, then clear the flag. Append everything to a list and join at the end. The common pitfall is building the result with repeated string concatenation in a loop, or splitting on underscore and forgetting the first word must stay lowercase. Another miss is uppercasing the first character of the whole string. The constraints remove the ugly cases, so don't add defensive code you don't need. It's O(n) time and O(n) space. The split-and-join version also works: keep the first piece, capitalize the rest. If the Google OA clock gets tight and your mind freezes, StealthCoder is the hedge that gives you the answer live, without the proctor seeing it.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Convert Snake Case 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Google reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Convert Snake Case to Camel Case FAQ

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

It's easy. One pass over the string with a boolean flag, or split on underscore and capitalize each part after the first. The only way to fail is sloppiness: wrong casing on the first word, or leaving an underscore in the output. Test with foo_bar before you submit.

What's the trick to converting snake_case to camelCase?+

Track whether the previous character was an underscore. If yes, uppercase the current character and append it. If it's an underscore itself, skip it and set the flag. Everything else gets appended as is. That's the whole solution in linear time.

Do I need to handle leading, trailing, or double underscores?+

No. The constraints say the input is valid snake_case, doesn't begin or end with an underscore, and has no consecutive underscores. Skip the defensive branches. Extra handling adds bug risk without earning anything on this problem.

Should I use split and join or a manual loop?+

Either passes. Split on underscore, keep the first word unchanged, capitalize the first letter of each remaining word, then join. A manual loop with a flag avoids the intermediate list. Pick whichever you can write without a bug in under five minutes.

How do I prepare for this in 48 hours?+

Write both versions once from memory, the flag loop and the split-join. Then run foo_bar, a single word with no underscore, and a three-part string like a_b_c. That covers the realistic edge cases. String-building problems like this one reward clean, boring code.

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

OA at Google?
Invisible during screen share
Get it