# 709. To Lower Case

## Description

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

Example 1:

Input: s = "Hello"
Output: "hello"


Example 2:

Input: s = "here"
Output: "here"


Example 3:

Input: s = "LOVELY"
Output: "lovely"


Constraints:

• 1 <= s.length <= 100
• s consists of printable ASCII characters.

## Solutions

• class Solution {
public String toLowerCase(String s) {
char[] cs = s.toCharArray();
for (int i = 0; i < cs.length; ++i) {
if (cs[i] >= 'A' && cs[i] <= 'Z') {
cs[i] |= 32;
}
}
return String.valueOf(cs);
}
}

• class Solution {
public:
string toLowerCase(string s) {
for (char& c : s) {
if (c >= 'A' && c <= 'Z') {
c |= 32;
}
}
return s;
}
};

• class Solution:
def toLowerCase(self, s: str) -> str:
return "".join([chr(ord(c) | 32) if c.isupper() else c for c in s])


• func toLowerCase(s string) string {
cs := []byte(s)
for i, c := range cs {
if c >= 'A' && c <= 'Z' {
cs[i] |= 32
}
}
return string(cs)
}

• function toLowerCase(s: string): string {
return [...s].map(c => String.fromCharCode(c.charCodeAt(0) | 32)).join('');
}


• impl Solution {
pub fn to_lower_case(s: String) -> String {
s.as_bytes()
.iter()
.map(|&c| char::from(if c >= b'A' && c <= b'Z' { c | 32 } else { c }))
.collect()
}
}