We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difficulty: 中等
Related Topics: 数组, 矩阵, 模拟
给你一个 m 行 n 列的矩阵 matrix ,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。
m
n
matrix
示例 1:
输入:matrix = [[1,2,3],[4,5,6],[7,8,9]] 输出:[1,2,3,6,9,8,7,4,5]
示例 2:
输入:matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 输出:[1,2,3,4,8,12,11,10,9,5,6,7]
提示:
m == matrix.length
n == matrix[i].length
1 <= m, n <= 10
-100 <= matrix[i][j] <= 100
Language: JavaScript
/** * @param {number[][]} matrix * @return {number[]} */ var spiralOrder = function(matrix) { let n = [] while (matrix.length) { n = _.concat(n, matrix.shift()) matrix = _.reverse(_.zip(...matrix)) } return n };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
54. 螺旋矩阵
Description
Difficulty: 中等
Related Topics: 数组, 矩阵, 模拟
给你一个
m
行n
列的矩阵matrix
,请按照 顺时针螺旋顺序 ,返回矩阵中的所有元素。示例 1:
示例 2:
提示:
m == matrix.length
n == matrix[i].length
1 <= m, n <= 10
-100 <= matrix[i][j] <= 100
Solution
Language: JavaScript
The text was updated successfully, but these errors were encountered: