Skip to content

Commit 5e9ca4d

Browse files
authored
Merge pull request 6boris#60 from hiepndd/develop
add solution problem 709
2 parents 9c7025d + b57acc9 commit 5e9ca4d

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+
func toLowerCase(str string) string {
6+
return strings.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+
func TestSolution(t *testing.T) {
9+
cases := []struct {
10+
name string
11+
input string
12+
expect string
13+
}{
14+
{"Test case 1", "HELLO", "hello"},
15+
{"Test case 2", "here", "here"},
16+
{"Test case 1", "LOVELY", "lovely"},
17+
}
18+
19+
for _, testcase := range cases {
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)