题目:
Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized.
Examples:
# returns "theStealthWarrior"
to_camel_case("the-stealth-warrior")
# returns "TheStealthWarrior"
to_camel_case("The_Stealth_Warrior")
中文简介:
其实就是去掉字符串中的‘-’或‘_‘连接符,然后除去第一个单词外,其他单词首字母大写连接
想法:
1、历遍字符串,找到单词间隔符’-‘和’_',然后通过两次循环找到首尾的间隔符,提取中间的单词,并让首字母大写
2、输入空字符串,返回空字符串
3、寻找第一个单词和最后一个单词,第一个单词通过一次历遍寻找第一个间隔符,然后跳出循环,最后一个单词通过储存最后次首间隔符的循环数,然后查找出后面的单词
实现: