Problem · String

Convert Snake Case to Camel Case

Learn this problem
EasyGoogleFULLTIMEPHONE SCREEN
See Google hiring insights

Problem statement

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.

More Google problems

drafts saved locally
public String toCamelCase(String s) {
  // Write your code here.
}
s"foo_bar"
expected"fooBar"
checking account