Skip to content

Commit 02bb8ba

Browse files
refactor 566
1 parent 1f2585a commit 02bb8ba

File tree

1 file changed

+0
-35
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-35
lines changed

src/main/java/com/fishercoder/solutions/_566.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 566. Reshape the Matrix
5-
*
6-
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.
7-
You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively.
8-
The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they were.
9-
If the 'reshape' operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.
10-
11-
Example 1:
12-
Input:
13-
nums =
14-
[[1,2],
15-
[3,4]]
16-
r = 1, c = 4
17-
Output:
18-
[[1,2,3,4]]
19-
Explanation:
20-
The row-traversing of nums is [1,2,3,4]. The new reshaped matrix is a 1 * 4 matrix, fill it row by row by using the previous list.
21-
22-
Example 2:
23-
Input:
24-
nums =
25-
[[1,2],
26-
[3,4]]
27-
r = 2, c = 4
28-
Output:
29-
[[1,2],
30-
[3,4]]
31-
Explanation:
32-
There is no way to reshape a 2 * 2 matrix to a 2 * 4 matrix. So output the original matrix.
33-
34-
Note:
35-
The height and width of the given matrix is in range [1, 100].
36-
The given r and c are all positive.
37-
*/
383
public class _566 {
394

405
public static class Solution1 {

0 commit comments

Comments
 (0)