You are given a string 'STR'. You have to convert the first alphabet of each word in a string to UPPER CASE.
For example:
If the given string 'STR' = ”I am a student of the third year” so you have to transform this string to ”I Am A Student Of The Third Year"
Note:
'STR' will contains only space and alphabets both uppercase and lowercase. The words will be separated by space.
The first line of input contains an integer ‘T’ denoting the number of test cases.
Then, the ‘T’ test cases follow.
The first and only line of each test case contains the string 'STR' that needs to be transformed.
Output format :
For each test case, print the final string after transformation.
The output of each test case will be printed in a separate line.
Note:
You don’t have to print anything; it has already been taken care of. Just implement the given function.
1 <= 'T' <= 10
1 <= |STR| <= 10^5
Where |STR| denotes the length of the string.
Time Limit: 1 sec
3
I love programming
they are playing cricket
good to see you
I Love Programming
They Are Playing Cricket
Good To See You
For the first test case:
Given string is “I love programming” we will convert every letter after space to uppercase to give the output as ”I Love Programming”.
For the second test case:
Given string is “they are playing cricket” we will convert every letter after space to uppercase to give the output as “They Are Playing Cricket”.
For the third test case:
Given string is “good to see you” we will convert every letter after space to uppercase to give the output as “Good To See You”.
3
why you are confused
Its a good day to be here
go and do your work
Why You Are Confused
Its A Good Day to Be Here
Go And Do Your Work
Try and think how you will know which character needs to be converted to uppercase.
The idea is to traverse the String and check for lowercase letters just after space; that is, you will check the letter after space if it is lowercase, then change it to uppercase.
O(N), Where ‘N’ denotes the string's length.
Since we are traversing the string once.
O(N), Where ‘N’ denotes the string's length.
Since we are using string builder to store the string.