Skip to content

Commit f33b6d9

Browse files
aQuaaQua
aQua
authored and
aQua
committed
helper 修改了细节
1 parent 5896a37 commit f33b6d9

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# [54. Spiral Matrix](https://leetcode.com/problems/spiral-matrix/)
2+
3+
## 题目
4+
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.
5+
6+
```
7+
For example,
8+
Given the following matrix:
9+
10+
[
11+
[ 1, 2, 3 ],
12+
[ 4, 5, 6 ],
13+
[ 7, 8, 9 ]
14+
]
15+
16+
You should return [1,2,3,6,9,8,7,4,5].
17+
```
18+
## 解题思路
19+
20+
21+
见程序注释
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Problem0054
2+
3+
func spiralOrder(matrix [][]int) []int {
4+
5+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package Problem0054
2+
3+
import (
4+
"testing"
5+
"fmt"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
type question struct {
11+
para
12+
ans
13+
}
14+
15+
// para 是参数
16+
type para struct {
17+
matrix [][]int
18+
}
19+
20+
// ans 是答案
21+
type ans struct {
22+
one []int
23+
}
24+
25+
func Test_Problem0054(t *testing.T) {
26+
ast := assert.New(t)
27+
28+
qs := []question{
29+
30+
question{
31+
para{
32+
,
33+
},
34+
ans{
35+
,
36+
},
37+
},
38+
39+
// 如需多个测试,可以复制上方元素。
40+
}
41+
42+
for _, q := range qs {
43+
a, p := q.ans, q.para
44+
fmt.Printf("~~%v~~\n", p)
45+
46+
ast.Equal(a.one, spiralOrder(p ), "输入:%v", p)
47+
}
48+
}

helper.v3/problem.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ func creatREADME(p problem) {
6565
6666
## 题目
6767
%s
68-
6968
## 解题思路
7069
71-
7270
见程序注释
7371
`
7472

0 commit comments

Comments
 (0)