Skip to content

Commit 272a492

Browse files
committed
Disallow generation of sparse matrices
After careful reading of the original problem's accompanying examples, it appears sparse matrices are considered *illegal* in this context.
1 parent 4d6394e commit 272a492

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎LeetCode Solutions/566_ReshapeTheMatrix_ccjmne.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ function* traverse(matrix) {
2424
* @param {number} c
2525
* @return {number[][]}
2626
*/
27-
var matrixReshape = function(nums, r, c) {
28-
if (nums.length * nums[0].length > r * c) {
29-
// The original matrix can't fit the requested shape
27+
var matrixReshape = function (nums, r, c) {
28+
if (nums.length * nums[0].length !== r * c) {
29+
// Both matrices don't hold the same number of elements.
3030
return nums;
3131
}
3232

0 commit comments

Comments
 (0)