难度: Easy
原题连接
内容描述
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
Example 1:
Input: "Hello"
Output: "hello"
Example 2:
Input: "here"
Output: "here"
Example 3:
Input: "LOVELY"
Output: "lovely"
思路 1 - 时间复杂度: O(N)- 空间复杂度: O(N)******
beats 75.75%
class Solution:
def toLowerCase(self, str):
"""
:type str: str
:rtype: str
"""
return ''.join(chr(ord(c) + 32) if 'A' <= c <= 'Z' else c for c in str)