You are given a string ‘str’, your task is to convert all the characters of the string into lowercase letters.
For example:You are given, ‘str’ = ‘AbcdEfgh’, in this string if you convert all the characters into lowercase, the string will be ‘abcdefgg’. Hence it is the answer.
The first line of input contains a single integer ‘T’, representing the number of test cases.
The first line of each test case contains a string ‘str’ representing the given string.
Output Format:
For each test case, print a single string representing the given string with all characters in lower case.
Print a separate line for each test case.
1 <= T <= 10
1 <= |str| <= 10^4
‘str’ will contain upper and lower case characters of the English alphabet.
Time Limit: 1 sec.
Note :
You do not need to print anything. It has already been taken care of. Just implement the given function.
Sample Input 1:
2
AbcdEfgh
AAAAb
abcdefgh
aaaab
For the first test case, ‘str’ = ‘AbcdEfgh’, in this string if you convert all the characters into lowercase, the string will be ‘abcdefgg’. Hence it is the answer.
For the second test case, ‘str’ = ‘AAAAb’, in this string if you convert all the characters into lowercase, the string will be ‘aaaab’. Hence it is the answer.
2
abcde
ABCDE
abcde
abcde
Try to process each character one at a time.
In this approach, we will iterate over the entire string and if we find any character that is in upper case, we can convert it into the lowercase version of itself.
Note: below, ASC(ch) means ASCII value of the character ‘ch’.
Algorithm:
O(N), Where N is the length of the string
We are iterating over each character of the string once, which will cost O(N) time. Hence the final time complexity of the algorithm is O(N)
O(1),
We are not using any extra space in this algorithm.