Skip to content

Commit 0c231cb

Browse files
committed
709.To Lower Case.
1 parent ad6bc22 commit 0c231cb

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.
3+
4+
5+
6+
Example 1:
7+
Input: s = "Hello"
8+
Output: "hello"
9+
10+
Example 2:
11+
Input: s = "here"
12+
Output: "here"
13+
14+
Example 3:
15+
Input: s = "LOVELY"
16+
Output: "lovely"
17+
18+
19+
Constraints:
20+
- 1 <= s.length <= 100
21+
- s consists of printable ASCII characters.
22+
*/
23+
class Solution {
24+
func toLowerCase(_ s: String) -> String {
25+
var result = ""
26+
for c in s {
27+
if c.isUppercase {
28+
result.append(c.lowercased())
29+
} else {
30+
result.append(c)
31+
}
32+
}
33+
return result
34+
}
35+
}
36+
37+
let s = Solution()
38+
let r = s.toLowerCase("LOVELY")
39+
print(r)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<playground version='5.0' target-platform='ios' buildActiveScheme='true' importAppTypes='true'>
3+
<timeline fileName='timeline.xctimeline'/>
4+
</playground>

Easy/709.To Lower Case.playground/playground.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
124. [Degree of an Array](https://github.com/recherst/leetcode-algtorithm/blob/main/Easy/697.Degree%20of%20an%20Array.playground/Contents.swift)
129129
125. [Long Pressed Name](https://github.com/recherst/leetcode-algtorithm/blob/main/Easy/925.Long%20Pressed%20Name.playground/Contents.swift)
130130
126. [Binary Search](https://github.com/recherst/leetcode-algtorithm/blob/main/Easy/704.Binary%20Search.playground/Contents.swift)
131+
127. [To Lower Case](https://github.com/recherst/leetcode-algtorithm/blob/main/Easy/709.To%20Lower%20Case.playground/Contents.swift)
131132

132133
#### Medium
133134

0 commit comments

Comments
 (0)