Algorithm
Problem Name: 709. To Lower Case
Problem Link: https://leetcode.com/problems/to-lower-case/
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.
Code Examples
#1 Code Example with Java Programming
Code -
Java Programming
class Solution {
public String toLowerCase(String s) {
return s.chars().mapToObj(c -> (char) c).map(Character::toLowerCase).map(String::valueOf)
.collect(Collectors.joining());
}
}
Copy The Code &
Try With Live Editor
Input
s = "Hello"
Output
"hello"
#2 Code Example with Python Programming
Code -
Python Programming
class Solution:
def toLowerCase(self, str):
return "".join(chr(ord(c) + 32) if 65 <= ord(c) <= 90 else c for c in str)
Copy The Code &
Try With Live Editor
Input
s = "Hello"
Output
"hello"
#3 Code Example with C# Programming
Code -
C# Programming
namespace LeetCode
{
public class _0709_ToLowerCase
{
public string ToLowerCase(string str)
{
return str.ToLower();
}
}
}
Copy The Code &
Try With Live Editor
Input
s = "here"
Output
"here"