Skip to content

Commit 00b6d1a

Browse files
committed
Add solution 709
1 parent 6d2d38e commit 00b6d1a

24 files changed

+764
-577
lines changed

README.md

Lines changed: 407 additions & 402 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package leetcode
2+
3+
func toLowerCase(s string) string {
4+
runes := []rune(s)
5+
diff := 'a' - 'A'
6+
for i := 0; i < len(s); i++ {
7+
if runes[i] >= 'A' && runes[i] <= 'Z' {
8+
runes[i] += diff
9+
}
10+
}
11+
return string(runes)
12+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package leetcode
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
type question709 struct {
9+
para709
10+
ans709
11+
}
12+
13+
// para 是参数
14+
// one 代表第一个参数
15+
type para709 struct {
16+
one string
17+
}
18+
19+
// ans 是答案
20+
// one 代表第一个答案
21+
type ans709 struct {
22+
one string
23+
}
24+
25+
func Test_Problem709(t *testing.T) {
26+
27+
qs := []question709{
28+
29+
{
30+
para709{"Hello"},
31+
ans709{"hello"},
32+
},
33+
34+
{
35+
para709{"here"},
36+
ans709{"here"},
37+
},
38+
39+
{
40+
para709{"LOVELY"},
41+
ans709{"lovely"},
42+
},
43+
}
44+
45+
fmt.Printf("------------------------Leetcode Problem 709------------------------\n")
46+
47+
for _, q := range qs {
48+
_, p := q.ans709, q.para709
49+
fmt.Printf("【input】:%v 【output】:%v\n", p, toLowerCase(p.one))
50+
}
51+
fmt.Printf("\n\n\n")
52+
}

leetcode/0709.To-Lower-Case/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# [709. To Lower Case](https://leetcode.com/problems/to-lower-case/)
2+
3+
4+
## 题目
5+
6+
Given a string `s`, return *the string after replacing every uppercase letter with the same lowercase letter*.
7+
8+
**Example 1:**
9+
10+
```
11+
Input: s = "Hello"
12+
Output: "hello"
13+
```
14+
15+
**Example 2:**
16+
17+
```
18+
Input: s = "here"
19+
Output: "here"
20+
```
21+
22+
**Example 3:**
23+
24+
```
25+
Input: s = "LOVELY"
26+
Output: "lovely"
27+
```
28+
29+
**Constraints:**
30+
31+
- `1 <= s.length <= 100`
32+
- `s` consists of printable ASCII characters.
33+
34+
## 题目大意
35+
36+
给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。
37+
38+
## 解题思路
39+
40+
- 简单题,将字符串中的大写字母转换成小写字母。
41+
42+
## 代码
43+
44+
```go
45+
func toLowerCase(s string) string {
46+
runes := [] rune(s)
47+
diff := 'a' - 'A'
48+
for i := 0; i < len(s); i++ {
49+
if runes[i] >= 'A' && runes[i] <= 'Z' {
50+
runes[i] += diff
51+
}
52+
}
53+
return string(runes)
54+
}
55+
```

website/content/ChapterFour/0700~0799/0707.Design-Linked-List.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,5 @@ func (this *MyLinkedList) DeleteAtIndex(index int) {
143143
----------------------------------------------
144144
<div style="display: flex;justify-content: space-between;align-items: center;">
145145
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0706.Design-HashMap/">⬅️上一页</a></p>
146-
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0710.Random-Pick-with-Blacklist/">下一页➡️</a></p>
146+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0709.To-Lower-Case/">下一页➡️</a></p>
147147
</div>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# [709. To Lower Case](https://leetcode.com/problems/to-lower-case/)
2+
3+
4+
## 题目
5+
6+
Given a string `s`, return *the string after replacing every uppercase letter with the same lowercase letter*.
7+
8+
**Example 1:**
9+
10+
```
11+
Input: s = "Hello"
12+
Output: "hello"
13+
```
14+
15+
**Example 2:**
16+
17+
```
18+
Input: s = "here"
19+
Output: "here"
20+
```
21+
22+
**Example 3:**
23+
24+
```
25+
Input: s = "LOVELY"
26+
Output: "lovely"
27+
```
28+
29+
**Constraints:**
30+
31+
- `1 <= s.length <= 100`
32+
- `s` consists of printable ASCII characters.
33+
34+
## 题目大意
35+
36+
给你一个字符串 s ,将该字符串中的大写字母转换成相同的小写字母,返回新的字符串。
37+
38+
## 解题思路
39+
40+
- 简单题,将字符串中的大写字母转换成小写字母。
41+
42+
## 代码
43+
44+
```go
45+
func toLowerCase(s string) string {
46+
runes := [] rune(s)
47+
diff := 'a' - 'A'
48+
for i := 0; i < len(s); i++ {
49+
if runes[i] >= 'A' && runes[i] <= 'Z' {
50+
runes[i] += diff
51+
}
52+
}
53+
return string(runes)
54+
}
55+
```
56+
57+
58+
----------------------------------------------
59+
<div style="display: flex;justify-content: space-between;align-items: center;">
60+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0707.Design-Linked-List/">⬅️上一页</a></p>
61+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0710.Random-Pick-with-Blacklist/">下一页➡️</a></p>
62+
</div>

website/content/ChapterFour/0700~0799/0710.Random-Pick-with-Blacklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,6 @@ func (this *Solution) Pick() int {
147147

148148
----------------------------------------------
149149
<div style="display: flex;justify-content: space-between;align-items: center;">
150-
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0707.Design-Linked-List/">⬅️上一页</a></p>
150+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0709.To-Lower-Case/">⬅️上一页</a></p>
151151
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0700~0799/0713.Subarray-Product-Less-Than-K/">下一页➡️</a></p>
152152
</div>

0 commit comments

Comments
 (0)