709. To Lower Case

Problem:

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"

思路

Solution (C++):

string toLowerCase(string str) {
    int n = str.length();
    for (int i = 0; i < n; ++i) {
        if (str[i] >= 65 && str[i] <= 90)  str[i] += 32;
    }
    return str;
}

性能

Runtime: 0 ms  Memory Usage: 6.1 MB

思路

Solution (C++):


性能

Runtime: ms  Memory Usage: MB

posted @ 2020-04-19 00:44  littledy  阅读(124)  评论(0编辑  收藏  举报