1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/将矩阵按对角线排序 [sort-the-matrix-diagonally].html
2022-03-29 12:43:11 +08:00

33 lines
1.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p><strong>矩阵对角线</strong> 是一条从矩阵最上面行或者最左侧列中的某个元素开始的对角线,沿右下方向一直到矩阵末尾的元素。例如,矩阵 <code>mat</code><code>6</code><code>3</code> 列,从 <code>mat[2][0]</code> 开始的 <strong>矩阵对角线</strong> 将会经过 <code>mat[2][0]</code><code>mat[3][1]</code><code>mat[4][2]</code></p>
<p>给你一个 <code>m * n</code> 的整数矩阵 <code>mat</code> ,请你将同一条 <strong>矩阵对角线 </strong>上的元素按升序排序后,返回排好序的矩阵。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/01/25/1482_example_1_2.png" style="height: 198px; width: 500px;" /></p>
<pre>
<strong>输入:</strong>mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]
<strong>输出:</strong>[[1,1,1,1],[1,2,2,2],[1,2,3,3]]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]
<strong>输出:</strong>[[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[22,27,31,36,50,66],[84,28,75,33,55,68]]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>m == mat.length</code></li>
<li><code>n == mat[i].length</code></li>
<li><code>1 <= m, n <= 100</code></li>
<li><code>1 <= mat[i][j] <= 100</code></li>
</ul>