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