-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathSpiralOrder.cs
64 lines (53 loc) · 1.18 KB
/
SpiralOrder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
题目名称:
螺旋矩阵
题目描述:
给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。
示例 1:
输入:
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
输出: [1,2,3,6,9,8,7,4,5]
示例 2:
输入:
[
[1, 2, 3, 4],
[5, 6, 7, 8],
[9,10,11,12]
]
输出: [1,2,3,4,8,12,11,10,9,5,6,7]
代码结构:
public class Solution {
public IList<int> SpiralOrder(int[][] matrix) {
}
}
题目链接:
https://leetcode-cn.com/problems/spiral-matrix/
*/
using System;
using System.Collections.Generic;
namespace SpiralOrder {
class Solution {
public IList<int> SpiralOrder(int[][] matrix) {
return new List<int>(){1, 2};
}
public void Print(IList<int> list){
foreach (int item in list)
{
Console.Write(item + " ");
}
Console.WriteLine();
}
public void Test() {
int[][] matrix = new int[][]{
new int[]{1, 2, 3},
new int[]{4, 5, 6},
new int[]{7, 8, 9},
};
Print(SpiralOrder(matrix));
}
}
}