709. To Lower Case
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 84% Topics: String
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(n)
# Space: O(1)
class Solution(object):
def toLowerCase(self, str):
"""
:type str: str
:rtype: str
"""
return "".join([chr(ord('a')+ord(c)-ord('A'))
if 'A' <= c <= 'Z' else c for c in str])
Solution from kamyu104/LeetCode-Solutions · MIT
Similar questions