顺时针打印矩阵
题目详情:
对于一个矩阵,请设计一个算法从左上角(mat[0][0])开始,顺时针打印矩阵元素。
给定int矩阵mat,以及它的维数nxm,请返回一个数组,数组中的元素为矩阵元素的顺时针输出。
测试样例:
[[1,2],[3,4]],2,2
返回:[1,2,4,3];
解题思路:
划分法,先遍历最外边的矩形,在按原来的方法层层递进。
class Printer {
public:
vector<int> clockwisePrint(vector<vector<int> > mat, int n, int m) {
vector