Skip to content

Commit 58ffc83

Browse files
authored
Create to-lower-case.cpp
1 parent 0dc2c75 commit 58ffc83

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

C++/to-lower-case.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
string toLowerCase(string str) {
7+
string result;
8+
for (const auto c : str) {
9+
if ('A' <= c && c <= 'Z') {
10+
result.push_back('a' + c - 'A');
11+
} else {
12+
result.push_back(c);
13+
}
14+
}
15+
return result;
16+
}
17+
};

0 commit comments

Comments
 (0)