LeetCode-709. To Lower Case

网友投稿 741 2022-08-25

LeetCode-709. To Lower Case

LeetCode-709. To Lower Case

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"

题解:

class Solution {public: string toLowerCase(string str) { int n = str.size(); if (n == 0) { return str; } for (int i = 0; i < n; i++) { if (str[i] >= 'A' && str[i] <= 'Z') { str[i] += 32; } } return str; }};

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如果没有 Android 世界会是什么样子?
下一篇:LeetCode-804. Unique Morse Code Words
相关文章

 发表评论

暂时没有评论,来抢沙发吧~