
Problem
Solution
Submissions
Convert a String into a Camel Case Format
Certification: Intermediate Level
Accuracy: 83.33%
Submissions: 18
Points: 5
Write a Python function to convert a given string into camel case format.
Example 1
- Input: s = "hello_world"
- Output: "helloWorld"
- Explanation:
- Step 1: Split the string "hello_world" by underscore character, resulting in ["hello", "world"].
- Step 2: Keep the first word "hello" as is (lowercase).
- Step 3: Capitalize the first letter of the remaining words: "world" becomes "World".
- Step 4: Join all words together: "hello" + "World" = "helloWorld".
- Step 5: Return the camel case string "helloWorld".
Example 2
- Input: s = "this_is_a_test"
- Output: "thisIsATest"
- Explanation:
- Step 1: Split the string "this_is_a_test" by underscore character, resulting in ["this", "is", "a", "test"].
- Step 2: Keep the first word "this" as is (lowercase).
- Step 3: Capitalize the first letter of the remaining words: "is" becomes "Is", "a" becomes "A", "test" becomes "Test".
- Step 4: Join all words together: "this" + "Is" + "A" + "Test" = "thisIsATest".
- Step 5: Return the camel case string "thisIsATest".
Constraints
- 1 <= len(string) <= 1000
- Time Complexity: O(n) where n is the length of the string
- Space Complexity: O(n)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Split the string by underscores.
- Capitalize the first letter of each word except the first word.
- Join the words together without spaces.