LeetCode709. To Lower Case

文章目录

    • 一、题目
    • 二、题解

一、题目

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

Example 1:

Input: s = “Hello”
Output: “hello”
Example 2:

Input: s = “here”
Output: “here”
Example 3:

Input: s = “LOVELY”
Output: “lovely”

Constraints:

1 <= s.length <= 100
s consists of printable ASCII characters.

二、题解

class Solution {
public:
    string toLowerCase(string s) {
        for(auto& c:s){
            c = tolower(c);
        }
        return s;
    }
};

你可能感兴趣的:(开发语言,c++,leetcode,算法)