Skip to content

Latest commit

 

History

History
35 lines (30 loc) · 767 Bytes

README_CN.md

File metadata and controls

35 lines (30 loc) · 767 Bytes

709. 转换成小写字母

实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串。

示例 1:

输入: "Hello"
输出: "hello"

示例 2:

输入: "here"
输出: "here"

示例 3:

输入: "LOVELY"
输出: "lovely"

题解 (Rust)

1. 题解

impl Solution {
    pub fn to_lower_case(str: String) -> String {
        let mut lower_case_str = String::new();
        for ch in str.chars() {
            lower_case_str.push(ch.to_ascii_lowercase());
        }
        lower_case_str
    }
}