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

Commite536e7d

Browse files
committed
🐗 add Add 1-100 problems template
1 parent397e29e commite536e7d

File tree

168 files changed

+5208
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+5208
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#[23. Merge k Sorted Lists]
2+
3+
##Description
4+
5+
Given two binary strings, return their sum (also a binary string).
6+
7+
The input strings are both**non-empty** and contains only characters`1` or`0`.
8+
9+
**Example 1:**
10+
11+
```
12+
Input: a = "11", b = "1"
13+
Output: "100"
14+
```
15+
16+
**Example 2:**
17+
18+
```
19+
Input: a = "1010", b = "1011"
20+
Output: "10101"
21+
```
22+
23+
**Tags:** Math, String
24+
25+
##题意
26+
>给你两个二进制串,求其和的二进制串。
27+
28+
##题解
29+
30+
###思路1
31+
>按照小学算数那么来做,用`carry` 表示进位,从后往前算,依次往前,每算出一位就插入到最前面即可,直到把两个二进制串都遍历完即可。
32+
33+
```go
34+
35+
```
36+
37+
###思路2
38+
>思路2
39+
```go
40+
41+
```
42+
43+
##结语
44+
45+
如果你同我一样热爱数据结构、算法、LeetCode,可以关注我 GitHub 上的 LeetCode 题解:[awesome-golang-leetcode][me]
46+
47+
[title]:https://leetcode.com/problems/merge-k-sorted-lists/description/
48+
[me]:https://github.com/kylesliu/awesome-golang-leetcode
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Solution
2+
3+
funcSolution(xbool)bool {
4+
returnx
5+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package Solution
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
funcTestSolution(t*testing.T) {
9+
//测试用例
10+
cases:= []struct {
11+
namestring
12+
inputsbool
13+
expectbool
14+
}{
15+
{"TestCacse 1",true,true},
16+
{"TestCacse 1",true,true},
17+
{"TestCacse 1",false,true},
18+
}
19+
20+
//开始测试
21+
for_,c:=rangecases {
22+
t.Run(c.name,func(t*testing.T) {
23+
ret:=Solution(c.inputs)
24+
if!reflect.DeepEqual(ret,c.expect) {
25+
t.Fatalf("expected: %v, but got: %v, with inputs: %v",
26+
c.expect,ret,c.inputs)
27+
}
28+
})
29+
}
30+
}
31+
32+
//压力测试
33+
funcBenchmarkSolution(b*testing.B) {
34+
35+
}
36+
37+
//使用案列
38+
funcExampleSolution() {
39+
40+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#[30. Substring with Concatenation of All Words][title]
2+
3+
##Description
4+
5+
Given two binary strings, return their sum (also a binary string).
6+
7+
The input strings are both**non-empty** and contains only characters`1` or`0`.
8+
9+
**Example 1:**
10+
11+
```
12+
Input: a = "11", b = "1"
13+
Output: "100"
14+
```
15+
16+
**Example 2:**
17+
18+
```
19+
Input: a = "1010", b = "1011"
20+
Output: "10101"
21+
```
22+
23+
**Tags:** Math, String
24+
25+
##题意
26+
>给你两个二进制串,求其和的二进制串。
27+
28+
##题解
29+
30+
###思路1
31+
>按照小学算数那么来做,用`carry` 表示进位,从后往前算,依次往前,每算出一位就插入到最前面即可,直到把两个二进制串都遍历完即可。
32+
33+
```go
34+
35+
```
36+
37+
###思路2
38+
>思路2
39+
```go
40+
41+
```
42+
43+
##结语
44+
45+
如果你同我一样热爱数据结构、算法、LeetCode,可以关注我 GitHub 上的 LeetCode 题解:[awesome-golang-leetcode][me]
46+
47+
[title]:https://leetcode.com/problems/substring-with-concatenation-of-all-words/description/
48+
[me]:https://github.com/kylesliu/awesome-golang-leetcode
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Solution
2+
3+
funcSolution(xbool)bool {
4+
returnx
5+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package Solution
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
funcTestSolution(t*testing.T) {
9+
//测试用例
10+
cases:= []struct {
11+
namestring
12+
inputsbool
13+
expectbool
14+
}{
15+
{"TestCacse 1",true,true},
16+
{"TestCacse 1",true,true},
17+
{"TestCacse 1",false,true},
18+
}
19+
20+
//开始测试
21+
for_,c:=rangecases {
22+
t.Run(c.name,func(t*testing.T) {
23+
ret:=Solution(c.inputs)
24+
if!reflect.DeepEqual(ret,c.expect) {
25+
t.Fatalf("expected: %v, but got: %v, with inputs: %v",
26+
c.expect,ret,c.inputs)
27+
}
28+
})
29+
}
30+
}
31+
32+
//压力测试
33+
funcBenchmarkSolution(b*testing.B) {
34+
35+
}
36+
37+
//使用案列
38+
funcExampleSolution() {
39+
40+
}

‎src/0031.Next-Permutation/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#[31. Next Permutation][title]
2+
3+
##Description
4+
5+
Given two binary strings, return their sum (also a binary string).
6+
7+
The input strings are both**non-empty** and contains only characters`1` or`0`.
8+
9+
**Example 1:**
10+
11+
```
12+
Input: a = "11", b = "1"
13+
Output: "100"
14+
```
15+
16+
**Example 2:**
17+
18+
```
19+
Input: a = "1010", b = "1011"
20+
Output: "10101"
21+
```
22+
23+
**Tags:** Math, String
24+
25+
##题意
26+
>给你两个二进制串,求其和的二进制串。
27+
28+
##题解
29+
30+
###思路1
31+
>按照小学算数那么来做,用`carry` 表示进位,从后往前算,依次往前,每算出一位就插入到最前面即可,直到把两个二进制串都遍历完即可。
32+
33+
```go
34+
35+
```
36+
37+
###思路2
38+
>思路2
39+
```go
40+
41+
```
42+
43+
##结语
44+
45+
如果你同我一样热爱数据结构、算法、LeetCode,可以关注我 GitHub 上的 LeetCode 题解:[awesome-golang-leetcode][me]
46+
47+
[title]:https://leetcode.com/problems/next-permutation/description/
48+
[me]:https://github.com/kylesliu/awesome-golang-leetcode

‎src/0031.Next-Permutation/Solution.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Solution
2+
3+
funcSolution(xbool)bool {
4+
returnx
5+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package Solution
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
funcTestSolution(t*testing.T) {
9+
//测试用例
10+
cases:= []struct {
11+
namestring
12+
inputsbool
13+
expectbool
14+
}{
15+
{"TestCacse 1",true,true},
16+
{"TestCacse 1",true,true},
17+
{"TestCacse 1",false,true},
18+
}
19+
20+
//开始测试
21+
for_,c:=rangecases {
22+
t.Run(c.name,func(t*testing.T) {
23+
ret:=Solution(c.inputs)
24+
if!reflect.DeepEqual(ret,c.expect) {
25+
t.Fatalf("expected: %v, but got: %v, with inputs: %v",
26+
c.expect,ret,c.inputs)
27+
}
28+
})
29+
}
30+
}
31+
32+
//压力测试
33+
funcBenchmarkSolution(b*testing.B) {
34+
35+
}
36+
37+
//使用案列
38+
funcExampleSolution() {
39+
40+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#[32. Longest Valid Parentheses][title]
2+
3+
##Description
4+
5+
Given two binary strings, return their sum (also a binary string).
6+
7+
The input strings are both**non-empty** and contains only characters`1` or`0`.
8+
9+
**Example 1:**
10+
11+
```
12+
Input: a = "11", b = "1"
13+
Output: "100"
14+
```
15+
16+
**Example 2:**
17+
18+
```
19+
Input: a = "1010", b = "1011"
20+
Output: "10101"
21+
```
22+
23+
**Tags:** Math, String
24+
25+
##题意
26+
>给你两个二进制串,求其和的二进制串。
27+
28+
##题解
29+
30+
###思路1
31+
>按照小学算数那么来做,用`carry` 表示进位,从后往前算,依次往前,每算出一位就插入到最前面即可,直到把两个二进制串都遍历完即可。
32+
33+
```go
34+
35+
```
36+
37+
###思路2
38+
>思路2
39+
```go
40+
41+
```
42+
43+
##结语
44+
45+
如果你同我一样热爱数据结构、算法、LeetCode,可以关注我 GitHub 上的 LeetCode 题解:[awesome-golang-leetcode][me]
46+
47+
[title]:https://leetcode.com/problems/longest-valid-parentheses/description/
48+
[me]:https://github.com/kylesliu/awesome-golang-leetcode
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Solution
2+
3+
funcSolution(xbool)bool {
4+
returnx
5+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package Solution
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
)
7+
8+
funcTestSolution(t*testing.T) {
9+
//测试用例
10+
cases:= []struct {
11+
namestring
12+
inputsbool
13+
expectbool
14+
}{
15+
{"TestCacse 1",true,true},
16+
{"TestCacse 1",true,true},
17+
{"TestCacse 1",false,true},
18+
}
19+
20+
//开始测试
21+
for_,c:=rangecases {
22+
t.Run(c.name,func(t*testing.T) {
23+
ret:=Solution(c.inputs)
24+
if!reflect.DeepEqual(ret,c.expect) {
25+
t.Fatalf("expected: %v, but got: %v, with inputs: %v",
26+
c.expect,ret,c.inputs)
27+
}
28+
})
29+
}
30+
}
31+
32+
//压力测试
33+
funcBenchmarkSolution(b*testing.B) {
34+
35+
}
36+
37+
//使用案列
38+
funcExampleSolution() {
39+
40+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp