Snake-Case Iterator to Camel Case
Problem statement
Convert the lowercase snake-case string produced by an iterator to camel case.
Preserve every leading and trailing underscore. Inside the remaining text, remove each nonempty run of underscores and uppercase the first following letter. If the input contains only underscores, return it unchanged.
Function
snakeIteratorToCamel(text: String) → StringExamples
Example 1
text = "__hello__world___"return = "__helloWorld___"Leading and trailing underscores are preserved, while the interior separator starts a new camel-case word.
Example 2
text = "___"return = "___"An all-underscore input is unchanged.
Constraints
1 <= text.length <= 200000.textcontains only lowercase English letters and underscores.