Convert Text to camelCase
Updated
Problem statement
Given a string s, convert it to camelCase and return the result.
A word is a longest run of letters; spaces, underscores and hyphens only separate words, and any number of them in a row count as one break. The result joins the words with nothing between them: the first word is written in lower case, and every later word has its first letter in upper case and the rest in lower case. Capital letters inside a word do not start a new word. If s has no letters, return an empty string.
Function
toCamelCase(s: String) → StringExamples
Example 1
s = "save the file"return = "saveTheFile"The words are save, the and file. The first stays lower case and the others start with a capital: "saveTheFile".
Example 2
s = " Total_ITEM-count "return = "totalItemCount"Spaces, underscores and hyphens all separate words, and the outer spaces are ignored. The words are Total, ITEM and count. The first becomes total, then Item and Count: "totalItemCount".
Example 3
s = "user ID"return = "userId"Only the first letter of a later word is a capital; the rest becomes lower case, so ID becomes Id. The answer is "userId".
Constraints
1 <= s.length <= 1000sconsists of English letters, spaces, underscores ('_') and hyphens ('-').
More Adobe Phone Screen questions
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
- All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
- Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
- Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
- Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
- Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
- Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026
Similar questions at other companies
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Format a Signed Integer with CommasHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Run-Length DecodingApple · PHONE SCREENApple interview questions
- Trace Pointer Rebinding and Pointee UpdatesArista Networks · PHONE SCREENArista Networks interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Decode and Store StringsAirbnb · PHONE SCREENAirbnb interview questions
- Delimiter-Parsing String Iteratoramo · PHONE SCREEN
Interview reports that mention this question
Adobe interview experiences
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences
- Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)