You are given a function to_lower() which takes a character array A as an argument.
Convert each character of A into lowercase characters if it exists. If the lowercase of a character does not exist, it remains unmodified. The uppercase letters from A to Z are converted to lowercase letters from a to z respectively.
Return the lowercase version of the given character array.
1 <= |A| <= 10^5
The only argument is a character array A.
Return the lowercase version of the given character array.
Input 1:
A = ['S', 'c', 'A', 'l', 'e', 'r', 'A', 'c', 'a', 'D', 'e', 'm', 'y']
Input 2:
A = ['S', 'c', 'a', 'L', 'e', 'r', '#', '2', '0', '2', '0']
Output 1:
['s', 'c', 'a', 'l', 'e', 'r', 'a', 'c', 'a', 'd', 'e', 'm', 'y']
Output 2:
['s', 'c', 'a', 'l', 'e', 'r', '#', '2', '0', '2', '0']
Explanation 1:
All the characters in the returned array are in lowercase alphabets.
Explanation 2:
Since there is no lowercase version for '#', '2'and '0'. It remains unchanged. Rest of the Uppercase alphabets are converted to lowercase accordingly.
function toLower(A){
for(let i = 0 ; i < A.length ; i++){
if(A[i] >= "A" && A[i] <= "Z"){
A[i] = String.fromCharCode(A[i].charCodeAt(0) ^ 32);
}
}
return A
}