Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb57acc9

Browse files
committed
add solution problem 709
1 parent9d38969 commitb57acc9

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

‎src/0709.To-Lower-Case/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#[709. To Lower Case][title]
2+
3+
##Description
4+
5+
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
6+
7+
**Example 1:**
8+
9+
```
10+
Input: "Hello"
11+
Output: "hello"
12+
```
13+
14+
15+
**Example 2:**
16+
17+
```
18+
Input: "LOVELY"
19+
Output: "lovely"
20+
```
21+
22+
**Example 3:**
23+
24+
```
25+
Input: "here"
26+
Output: "here"
27+
```
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
[title]:https://leetcode.com/problems/to-lower-case/
39+

‎src/0709.To-Lower-Case/Solution.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package Solution
2+
3+
import"strings"
4+
5+
functoLowerCase(strstring)string {
6+
returnstrings.ToLower(str)
7+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package Solution
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
funcTestSolution(t*testing.T) {
9+
cases:= []struct {
10+
namestring
11+
inputstring
12+
expectstring
13+
}{
14+
{"Test case 1","HELLO","hello"},
15+
{"Test case 2","here","here"},
16+
{"Test case 1","LOVELY","lovely"},
17+
}
18+
19+
for_,testcase:=rangecases {
20+
t.Run(testcase.name,func(t*testing.T) {
21+
got:=toLowerCase(testcase.input)
22+
if!reflect.DeepEqual(got,testcase.expect) {
23+
t.Fatalf("expected: %v, but got: %v, with input: %v ",testcase.expect,got,testcase.input)
24+
}
25+
})
26+
}
27+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp