列表

详情


709. 转换成小写字母

给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。

 

示例 1:

输入:s = "Hello"
输出:"hello"

示例 2:

输入:s = "here"
输出:"here"

示例 3:

输入:s = "LOVELY"
输出:"lovely"

 

提示:

原站题解

去查看

上次编辑到这里,代码来自缓存 点击恢复默认模板
class Solution { public: string toLowerCase(string s) { } };

golang 解法, 执行用时: 0 ms, 内存消耗: 1.9 MB, 提交时间: 2021-05-26 10:22:52

func toLowerCase(s string) string {
    var b []byte = []byte(s)
    for i := 0; i < len(b); i++ {
        if b[i] >= 'A' && b[i] <= 'Z' {
            b[i] += 32
        }
    }
    return string(b)
}

golang 解法, 执行用时: 0 ms, 内存消耗: 1.9 MB, 提交时间: 2021-05-26 09:58:08

func toLowerCase(s string) string {
    return strings.ToLower(s)
}

上一题