Suppose we have a list of words, we have to concatenate them in camel case format.
So, if the input is like ["Hello", "World", "Python", "Programming"], then the output will be "helloWorldPythonProgramming"
To solve this, we will follow these steps −
s := blank string
for each word in words −
make first letter word uppercase and rest lowercase
concatenate word with s
ret := s by converting first letter of s as lowercase
return ret
Let us see the following implementation to get better understanding −
Example
class Solution: def solve(self, words): s = "".join(word[0].upper() + word[1:].lower() for word in words) return s[0].lower() + s[1:] ob = Solution() words = ["Hello", "World", "Python", "Programming"] print(ob.solve(words))
Input
["Hello", "World", "Python", "Programming"]
Output
helloWorldPythonProgramming