Skip to content

Latest commit

 

History

History
78 lines (31 loc) · 750 Bytes

0709._To_Lower_Case.md

File metadata and controls

78 lines (31 loc) · 750 Bytes

1. Two Sum

难度: 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)