← 返回 ramp 的题目列表Convert snake_case names to lowerCamelCase
类型:qbank
Convert a variable name from snake_case to lowerCamelCase: strip word-separating underscores and capitalize the first letter of every word after the first. Leading and trailing underscores must be preserved, and runs of multiple underscores between words count as a single separator.
Examples
Example 1:
Input: name = "my_counter"
Output: "myCounter"
Explanation:
The separator is removed and "counter" is capitalized because it is not the first word.
Example 2:
Input: name = "__user_account_id__"
Output: "__userAccountId__"
Explanation:
The two leading and two trailing underscores are preserved, while the middle words become lower camel case.
Example 3:
Input: name = "already"
Output: "already"
Explanation:
A single-word name has no separators to convert.
Constraints
1 <= name.length <= 10^5
name consists only of lowercase English letters and underscores.
After removing leading and trailing underscores, the remaining core contains at least one lowercase English letter.