709. To Lower Case

problem

solution

1
2
3
4
5
6
7
8
9
10
11
class Solution {
public:
string toLowerCase(string s) {
string str;
for(char c: s){
if(c>='A' && c<='Z') c+=32;
str+=c;
}
return str;
}
};

analysis

  • time complexity O(n)
  • space complexity O(1)