question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
number-of-ways-to-split-array
One Line Solution
one-line-solution-by-charnavoki-eaj1
null
charnavoki
NORMAL
2025-01-03T07:09:38.601727+00:00
2025-01-03T07:09:38.601727+00:00
19
false
```javascript [] const waysToSplitArray = ([a, ...nums], s = nums.reduce((x, y) => y + x)) => nums.reduce((w, v) => ([w, a, s] = [w + (a >= s), a + v, s - v])[0], 0); ```
2
0
['JavaScript']
0
number-of-ways-to-split-array
Step-by-Step Solution: Number of Ways to Split Array (100% Easy, 0ms)
step-by-step-solution-number-of-ways-to-8vc9g
IntuitionThe problem is about finding the number of ways to split an array into two non-empty parts such that the sum of the first part is greater than or equal
user1233nm
NORMAL
2025-01-03T07:02:49.077530+00:00
2025-01-04T05:51:41.615688+00:00
26
false
# Intuition The problem is about finding the number of ways to split an array into two non-empty parts such that the sum of the first part is greater than or equal to the sum of the second part. The **prefix sum technique** provides an efficient way to calculate the cumulative sum and perform quick range queries. # Ap...
2
0
['Array', 'Prefix Sum', 'C++', 'Java', 'Go', 'Python3', 'Rust', 'JavaScript']
1
number-of-ways-to-split-array
Beats 100% Easy C++ Using Prefix and Suffix -- Ways to Split Array into Two Parts
beats-100-easy-c-using-prefix-and-suffix-c9lb
Method 1 -- Optimized way of the second method given after thisIntuitionThe task is to split the array into two non-empty parts such that the sum of elements in
Abhishek-Verma01
NORMAL
2025-01-03T06:40:32.480841+00:00
2025-01-03T06:40:32.480841+00:00
27
false
# Method 1 -- Optimized way of the second method given after this # Intuition <!-- Describe your first thoughts on how to solve this problem. --> The task is to split the array into two non-empty parts such that the sum of elements in the left part `(lSum)` is greater than or equal to the sum of elements in the right p...
2
0
['Array', 'Sliding Window', 'Suffix Array', 'Prefix Sum', 'C++']
0
number-of-ways-to-split-array
Simple prefixSum solution✅✅
simple-prefixsum-solution-by-_shubham_22-67y1
IntuitionThe task is to find the number of ways to split an array nums nums such that: Both parts are non-empty. The sum of the left part (prefixSum) is greater
_shubham_22
NORMAL
2025-01-03T06:11:34.107285+00:00
2025-01-03T06:11:34.107285+00:00
4
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The task is to find the number of ways to split an array nums nums such that: 1. Both parts are non-empty. 1. The sum of the left part (prefixSum) is greater than or equal to the sum of the right part (suffixSum). By observing: - prefixSum...
2
0
['Array', 'Prefix Sum', 'C++']
0
number-of-ways-to-split-array
🌟 Beat 100% | 🔥Optimized Approach 💡 | Beginner-Friendly 🐣 | Easy Solution ✅
beat-100-optimized-approach-beginner-fri-62ra
Intuition 🧠 The goal is to find splits in the array such that the sum of the left part is greater than or equal to the sum of the right part. This involves calc
shubhamrajpoot_
NORMAL
2025-01-03T05:45:59.828286+00:00
2025-01-03T05:45:59.828286+00:00
52
false
# Intuition 🧠 - The goal is to find splits in the array such that the sum of the left part is greater than or equal to the sum of the right part. This involves calculating prefix sums efficiently. # *Brute Force Approach* 🚶‍♂️ ## *Approach*: - Compute two prefix sum arrays (left and right) for the left and right pa...
2
0
['Prefix Sum', 'Python', 'C++', 'Java', 'Go', 'Rust', 'Ruby', 'JavaScript', 'C#', 'Dart']
0
number-of-ways-to-split-array
2 ms🚀|| 100% Beats ✅ || JAVA || Simple Logic🌟
2-ms-100-beats-java-simple-logic-by-siva-p7w0
IntuitionApproachComplexity Time complexity: O(n + (n-1)) Space complexity: Code
Sivaram11
NORMAL
2025-01-03T05:29:23.074767+00:00
2025-01-03T05:29:23.074767+00:00
27
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> ![Screenshot 2025-01-03 105305.png](https://assets.leetcode.com/users/images/23762585-f229-4f15-a0d2-ade060680b41_1735881825.258632.png) # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O...
2
0
['Java']
1
number-of-ways-to-split-array
🔥 Super Clean 4-Line C++ Solution | One-Pass Magic!
super-clean-4-line-c-solution-one-pass-m-2kr8
IntuitionThe problem requires determining the number of valid ways to split the array such that the sum of elements on the left side is greater than or equal to
sachin1604
NORMAL
2025-01-03T05:24:59.669482+00:00
2025-01-03T05:24:59.669482+00:00
16
false
# Intuition The problem requires determining the number of valid ways to split the array such that the sum of elements on the left side is greater than or equal to the sum of elements on the right side. The key insight is that we can compute the prefix sum and suffix sum efficiently by traversing the array once and upd...
2
0
['Array', 'Prefix Sum', 'C++']
1
number-of-ways-to-split-array
Easy Solution || 2ms ✅ || Beats 100%👌|| Prefix Sum 👍
easy-solution-2ms-beats-100-prefix-sum-b-fzwu
IntuitionApproachComplexity Time complexity: Space complexity: Code
Sorna_Prabhakaran
NORMAL
2025-01-03T05:22:12.752428+00:00
2025-01-03T05:22:12.752428+00:00
15
false
# Intuition ![Screenshot 2025-01-03 105031.png](https://assets.leetcode.com/users/images/fa3d46a0-8e71-4353-9c6b-96008c1260c4_1735881718.7586474.png) <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <...
2
0
['Java']
0
number-of-ways-to-split-array
Java and C++, Easy Solution
java-and-c-easy-solution-by-divyaaroraa-3lx7
IntuitionThe problem asks for the number of valid splits of an array, where the sum of the left part is greater than or equal to the sum of the right part. This
divyaaroraa
NORMAL
2025-01-03T05:18:36.918706+00:00
2025-01-03T05:18:36.918706+00:00
11
false
# Intuition The problem asks for the number of valid splits of an array, where the sum of the left part is greater than or equal to the sum of the right part. This can be efficiently solved using prefix sums. <!-- Describe your first thoughts on how to solve this problem. --> # Approach 1. First, calculate the total s...
2
0
['C++']
0
number-of-ways-to-split-array
Beats 100% users in JAVA
beats-100-users-in-java-by-muskaan_1801-akyv
IntuitionApproachComplexity Time complexity: Space complexity: Code
muskaan_1801
NORMAL
2025-01-03T05:12:29.978830+00:00
2025-01-03T05:12:29.978830+00:00
16
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
2
0
['Java']
0
number-of-ways-to-split-array
Counting Valid Splits in an Array Based on Sum Comparison
counting-valid-splits-in-an-array-based-oen8t
IntuitionThe problem asks us to determine the number of valid splits in the array such that the sum of the left subarray is greater than or equal to the sum of
jasurbek_fm
NORMAL
2025-01-03T05:05:34.492787+00:00
2025-01-03T05:05:34.492787+00:00
5
false
# Intuition The problem asks us to determine the number of valid splits in the array such that the sum of the left subarray is greater than or equal to the sum of the right subarray. A straightforward approach involves computing prefix sums and comparing them for each potential split. # Approach **1. Calculate Total S...
2
0
['Prefix Sum', 'C++']
0
number-of-ways-to-split-array
C++ solution using prefix sum and suffix sum. stay permission less
c-solution-using-prefix-sum-and-suffix-s-3yho
IntuitionApproachsimply create the prefix sum array and suffix sum array and then if sum of prefix is grreater than equal to the next index of suffix sum then p
Gufrankhan
NORMAL
2025-01-03T03:55:41.019573+00:00
2025-01-03T03:55:41.019573+00:00
17
false
# Intuition # Approach simply create the prefix sum array and suffix sum array and then if sum of prefix is grreater than equal to the next index of suffix sum then possible to split the array we count the number of ways and return it; # Complexity - Time complexity: 0(N) // size of nums - Space complex...
2
0
['C++']
0
number-of-ways-to-split-array
Number of Ways to Split Array- Two Approaches✅|| Beats 100% 🚀|| Prefix Sum & Single Pass || JAVA ☕
number-of-ways-to-split-array-two-approa-5hoh
IntuitionThe problem asks us to find the number of valid splits in an array such that the sum of the left part is greater than or equal to the sum of the right
Megha_Mathur18
NORMAL
2025-01-03T03:50:33.506618+00:00
2025-01-03T03:50:33.506618+00:00
20
false
# Intuition The problem asks us to find the number of valid splits in an array such that the sum of the left part is greater than or equal to the sum of the right part. My initial thought was to maintain prefix sums for both left and right parts of the array, but I later realized that a single pass with cumulative sums...
2
0
['Java']
0
number-of-ways-to-split-array
clear code with simple looping and tracking | 100% beats
clear-code-with-simple-looping-and-track-xe35
Approach Tracking the prefix sum and sufix sum with simple for loop and comparing prefix and sufix. use long varible for prefix and sufix else we facing the err
keshavakumar_jr
NORMAL
2025-01-03T03:37:57.567070+00:00
2025-01-03T03:37:57.567070+00:00
12
false
# Approach <!-- Describe your approach to solving the problem. --> 1. Tracking the prefix sum and sufix sum with simple for loop and comparing prefix and sufix. 2. use long varible for prefix and sufix else we facing the error. 3. upvote if u like my approch and explanation. # Complexity - Time complexity:O(n) <!-- Ad...
2
0
['Prefix Sum', 'Java']
0
number-of-ways-to-split-array
Simplest Code🚀 || Beat 100% || Complete Explanation
simplest-code-beat-100-complete-explanat-3lwn
Upvote if you find this helpful! 👍IntuitionThe problem involves finding the number of valid splits of an array such that the sum of the left part is greater tha
CodeNikET
NORMAL
2025-01-03T03:31:39.807944+00:00
2025-01-03T03:31:39.807944+00:00
36
false
# **Upvote if you find this helpful! 👍** # Intuition The problem involves finding the number of valid splits of an array such that the sum of the left part is greater than or equal to the sum of the right part. To achieve this, we can calculate prefix sums and suffix sums for efficient comparisons at each split point...
2
0
['Array', 'Math', 'Prefix Sum', 'C++']
1
number-of-ways-to-split-array
JAVA || 3MS 🚀🚀|| BEATS 60 % || EASY SOLUTION✅✅ ||
java-3ms-beats-60-easy-solution-by-kavi_-yqn3
IntuitionApproachComplexity Time complexity: Space complexity: Code
kavi_k
NORMAL
2025-01-03T03:10:30.370528+00:00
2025-01-03T03:10:30.370528+00:00
18
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
2
0
['Java']
0
largest-submatrix-with-rearrangements
[C++] Clean and Clear, With Intuitive Pictures, O(m * n * logn)
c-clean-and-clear-with-intuitive-picture-pcwo
This question is very similar to \n84. Largest Rectangle in Histogram\n85. Maximal Rectangle\n\nThey are both hard questions, so don\'t be frustrated if you can
aincrad-lyu
NORMAL
2021-01-17T04:15:47.754131+00:00
2021-01-17T08:29:19.230247+00:00
13,659
false
This question is very similar to \n[84. Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/)\n[85. Maximal Rectangle](https://leetcode.com/problems/maximal-rectangle/)\n\nThey are both hard questions, so don\'t be frustrated if you cannot solve it in the contest.\n\nFirst think...
821
19
[]
76
largest-submatrix-with-rearrangements
Java | 6ms | easy understanding with comments and images
java-6ms-easy-understanding-with-comment-sqoi
This is like this one https://leetcode.com/problems/maximal-rectangle/\nbut since each block can move, we cannot use that method (it will cause TLE).\nMy though
rioto9858
NORMAL
2021-01-17T04:10:11.353425+00:00
2021-01-17T13:59:57.508304+00:00
6,200
false
This is like this one [https://leetcode.com/problems/maximal-rectangle/](http://)\nbut since each block can move, we cannot use that method (it will cause TLE).\nMy thought is like this : \n1. we need the rectangle for each column so we need to memorize that. --> change the matrix\n2. the columns can move ----> sort...
206
5
[]
16
largest-submatrix-with-rearrangements
【Video】Give me 10 minutes - how we think about a solution
video-give-me-10-minutes-how-we-think-ab-b8eb
Intuition\nUsing sort for width.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/odAv92zWKqs\n\nThese days, many people watch my video more than 70% of whole tim
niits
NORMAL
2023-11-26T07:49:27.916070+00:00
2023-11-28T20:00:39.302975+00:00
4,215
false
# Intuition\nUsing sort for width.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/odAv92zWKqs\n\nThese days, many people watch my video more than 70% of whole time, which is good to my channel reputation. Thank you!\n\nI\'m creating this video or post with the goal of ensuring that viewers, whether they read the post o...
134
0
['C++', 'Java', 'Python3', 'JavaScript']
11
largest-submatrix-with-rearrangements
✅ Beats 100% - Explained with [ Video ] - Simple Sorting - Visualized Too
beats-100-explained-with-video-simple-so-b8ia
\n\n # YouTube Video Explanation:\n\n<a href="https://youtu.be/biPaIwFMISI">https://youtu.be/biPaIwFMISI</a>\n\n**\uD83D\uDD25 Please like, share, and subscribe
lancertech6
NORMAL
2023-11-26T03:31:35.574328+00:00
2023-11-27T17:23:02.079063+00:00
11,200
false
![Screenshot 2023-11-26 085349.png](https://assets.leetcode.com/users/images/07ea17af-c17d-4dd3-be57-e1a8b31a82d3_1700969160.5604217.png)\n\n<!-- # YouTube Video Explanation:\n\n[https://youtu.be/biPaIwFMISI](https://youtu.be/biPaIwFMISI)\n\n**\uD83D\uDD25 Please like, share, and subscribe to support our channel\'s mis...
84
2
['Array', 'Greedy', 'Sorting', 'Matrix', 'Python', 'C++', 'Java', 'JavaScript']
13
largest-submatrix-with-rearrangements
C++ Solution | Easy Implementation
c-solution-easy-implementation-by-invuln-nbqp
\nint largestSubmatrix(vector<vector<int>>& matrix) {\n \n int i, j, ans = 0, n = matrix.size(), m = matrix[0].size();\n \n for(i =
invulnerable
NORMAL
2021-01-17T04:00:49.698617+00:00
2021-01-17T13:43:38.351537+00:00
4,775
false
```\nint largestSubmatrix(vector<vector<int>>& matrix) {\n \n int i, j, ans = 0, n = matrix.size(), m = matrix[0].size();\n \n for(i = 0; i < m; i++)\n {\n for(j = 1; j < n; j++)\n {\n if(matrix[j][i] == 1)\n matrix[j][i] = matri...
82
4
[]
14
largest-submatrix-with-rearrangements
Optimal O(m*n) time, O(n) space, no sort :)
optimal-omn-time-on-space-no-sort-by-ale-lo45
We first explain an O(m * n * log n) algorithm that, internally, uses an O(n * log n) sort for each row. That algorithm is similar to most other solutions for
alex_salcianu
NORMAL
2021-01-17T04:43:49.992374+00:00
2021-01-18T09:47:08.263615+00:00
1,725
false
We first explain an O(m * n * log n) algorithm that, internally, uses an O(n * log n) sort for each row. That algorithm is similar to most other solutions for this problem. It is good-enough for the current tests, but not optimal. Then, we explain how to remove that sort() and obtain an O(m * n) algorithm. Finally,...
32
0
[]
4
largest-submatrix-with-rearrangements
Explanation with Picture. Variation of Maximal Rectangle and Largest Rectangle in Histogram
explanation-with-picture-variation-of-ma-s9l3
This problem is very similar to Maximum rectangular area and Largest Rectangle in Histogram. The only variation here is that we can swap the columns and put the
cut_me_half
NORMAL
2021-01-17T04:01:00.137554+00:00
2021-01-18T04:57:20.524436+00:00
2,406
false
This problem is very similar to Maximum rectangular area and Largest Rectangle in Histogram. The only variation here is that we can swap the columns and put the columns next to each other to optimize the answer.\n\nWell, we can just sort the current row in which we are and then can directly use `largestRectangularArea`...
31
8
[]
7
largest-submatrix-with-rearrangements
Easy to Read || Beginner friendly || No Fluff || C++/Java/Python
easy-to-read-beginner-friendly-no-fluff-zu9q1
Treat every column in the matrix as a height bar, where the base of that height represents total number of consecutives ones above it included himself. \n\n\n
Cosmic_Phantom
NORMAL
2023-11-26T02:43:39.314790+00:00
2023-11-26T04:18:22.814244+00:00
3,460
false
Treat every column in the matrix as a height bar, where the base of that height represents total number of consecutives ones above it included himself. \n\n```\n [[0,0,1],\n [1,1,1],\n [1,0,1]]\nheight->[2,0,3] -> sort -> [3,2,0] -> \n```\n\nNow iterate over this sorted row and consider the largest ...
26
0
['Array', 'Math', 'Sorting', 'Matrix']
5
largest-submatrix-with-rearrangements
[Python3] Concise solution
python3-concise-solution-by-kunqian-0-dcvw
Intuition\n\nFor each row, find the histogram height of each column. \nSort it and find the max rectangle you could find(refer to Question 84).\n\n# Complexity\
kunqian-0
NORMAL
2021-01-17T04:03:20.569527+00:00
2021-01-17T07:18:56.342083+00:00
957
false
# **Intuition**\n\nFor each row, find the histogram height of each column. \nSort it and find the max rectangle you could find(refer to [Question 84]( https://leetcode.com/problems/largest-rectangle-in-histogram/)).\n<br/>\n# **Complexity**\nTime: `O(m * n * log(n))`\nSpace: `O(n)`\n<br/>\n# **Python3**\n```python\ndef...
21
7
[]
2
largest-submatrix-with-rearrangements
🔥Beginner Friendly Solution with Detail Explanation🔥|| 🔥Daily Challenges🔥
beginner-friendly-solution-with-detail-e-qwae
Intuition\n\n\n# Complexity\n- Time complexity:O(2nm)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e
Shree_Govind_Jee
NORMAL
2023-11-26T03:46:54.680703+00:00
2023-11-26T03:46:54.680725+00:00
1,214
false
# Intuition\n![image.png](https://assets.leetcode.com/users/images/e4acabd8-4171-48ab-ba36-a9a3b027f6b8_1700970309.7230844.png)\n\n# Complexity\n- Time complexity:$$O(2*n*m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\...
19
1
['Array', 'Greedy', 'Sorting', 'Matrix', 'Java']
5
largest-submatrix-with-rearrangements
Javascript | Simple Solution w/ Explanation & Visuals | beats 100% / 100%
javascript-simple-solution-w-explanation-f57b
Idea:\n\nSince the elements in each column can\'t move, we can think of each consecutive group of 1s in each column as a solid pillar within that column.\n\nmat
sgallivan
NORMAL
2021-01-18T07:31:21.992871+00:00
2021-01-18T07:31:41.047778+00:00
608
false
***Idea:***\n\nSince the elements in each column can\'t move, we can think of each consecutive group of **1**s in each column as a solid pillar within that column.\n```\nmatrix: [ [ 0, 1, 0, 1, 0 ],\n [ 1, 1, 0, 1, 1 ],\n [ 1, 1, 1, 0, 1 ],\n [ 1, 0, 1, 1, 0 ],\n [ 1, 1, 1,...
17
0
['JavaScript']
3
largest-submatrix-with-rearrangements
Simple Python3 | 9 Lines | Beats 100% | Detailed Explanation
simple-python3-9-lines-beats-100-detaile-a0iz
Logic: Prefix sum from top to the bottom row for every column, by doing this we have number of continuous 1st stacked on top so far at matrix[i][j] . So for exa
sushanthsamala
NORMAL
2021-01-17T04:01:17.262825+00:00
2021-01-17T14:15:46.860527+00:00
2,169
false
Logic: Prefix sum from top to the bottom row for every column, by doing this we have number of continuous 1st stacked on top so far at matrix[i][j] . So for example if the matrix is \n[0,0,1]\n[1,1,1]\n[1,0,1]\nWe have the prefix summed matrix:\n[0, 0, 1]\n[1, 1, 2]\n[2, 0, 3]\nNow the we could just go row by row and c...
17
2
['Python3']
3
largest-submatrix-with-rearrangements
Beat 100%! O(m*n*logn ) easy solution
beat-100-omnlogn-easy-solution-by-lawren-47rr
Example 1\n\n[0,0,1],\n[1,1,1],\n[1,0,1] \n\nFor every column, we count the the number of continuous 1 by the current position. the result matrix will be\n\n[0
lawrenceflag
NORMAL
2021-01-17T04:01:22.574114+00:00
2021-01-17T04:30:14.089900+00:00
1,120
false
Example 1\n\n[0,0,1],\n[1,1,1],\n[1,0,1] \n\nFor every column, we count the the number of continuous 1 by the current position. the result matrix will be\n\n[0,0,1],\n[1,1,2],\n[2,0,3] \n\nNow let\u2019s consider every row. \nFor the first row, we reversely sort the row\nWe got [1,0,0]. It\'s very easy to get the larg...
16
8
[]
4
largest-submatrix-with-rearrangements
C++ sort row vs Freq count||124 ms Beats 98.30%
c-sort-row-vs-freq-count124-ms-beats-983-4n3q
Intuition\n Describe your first thoughts on how to solve this problem. \nUse the matrix to store the height for each column.\n\nLater try other approach!\n# App
anwendeng
NORMAL
2023-11-26T03:10:57.628557+00:00
2023-11-26T08:34:09.690840+00:00
2,575
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUse the `matrix` to store the height for each column.\n\nLater try other approach!\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUse sort!\n\nThe approach using counting sort leads to TLE & fails , for the testcase...
11
1
['Array', 'Hash Table', 'Sorting', 'Counting Sort', 'C++']
3
largest-submatrix-with-rearrangements
【Video】Sorting solution
video-sorting-solution-by-niits-ylte
Intuition\nUsing sort for width.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/odAv92zWKqs\n\nThese days, many people watch my video more than 70% of whole tim
niits
NORMAL
2024-04-23T16:38:01.350989+00:00
2024-04-23T16:38:01.351018+00:00
129
false
# Intuition\nUsing sort for width.\n\n---\n\n# Solution Video\n\nhttps://youtu.be/odAv92zWKqs\n\nThese days, many people watch my video more than 70% of whole time, which is good to my channel reputation. Thank you!\n\nI\'m creating this video or post with the goal of ensuring that viewers, whether they read the post o...
8
0
['C++', 'Java', 'Python3', 'JavaScript']
0
largest-submatrix-with-rearrangements
Beat 100% - Easy solution with explanation similar problem - maximal-rectangle
beat-100-easy-solution-with-explanation-j9phz
intuition\n matrix[i][j] is sum of continous 1\'s\n sort the each row to keep largest matrix because we can swap the columns\n\nadd the continous 1\'s from top
aravind_dev
NORMAL
2021-01-17T04:03:08.636047+00:00
2021-01-17T15:36:20.754502+00:00
617
false
**intuition**\n* matrix[i][j] is sum of continous 1\'s\n* sort the each row to keep largest matrix because we can swap the columns\n\nadd the continous 1\'s from top to bottom.\nsort the each row to find the largest matrix\n\nEx:\n```\nmatrix= [[1,0,0],\n\t\t[1,0,1],\n\t\t[1,1,1]];\n```\n\nafter counting continous 1\'s...
7
0
[]
5
largest-submatrix-with-rearrangements
[C++] count 1s and then sort
c-count-1s-and-then-sort-by-ddddyliu-7cbf
\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n int m = matrix.size(), n = matrix[0].size();\n vector<vecto
ddddyliu
NORMAL
2021-01-17T04:01:56.924656+00:00
2021-01-17T04:30:09.288373+00:00
804
false
```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n int m = matrix.size(), n = matrix[0].size();\n vector<vector<int>> cntOne(m, vector<int>(n, 0));\n for (int j = 0; j < n; j++) {\n if (matrix[0][j] == 1) {cntOne[0][j] = 1;}\n }\n for ...
7
1
['C', 'Sorting']
1
largest-submatrix-with-rearrangements
😀 Fully Explained Solution With Example and Dry Run 💡
fully-explained-solution-with-example-an-nna4
Problem \nFinding the maximum area of submatrix which has 1 in its each cell.\n\n# How do we calculate area?\nArea = Length * breadth\nIn this problem, we will
mohd-usman
NORMAL
2023-11-26T15:43:56.004730+00:00
2023-11-26T15:43:56.004755+00:00
297
false
# Problem \nFinding the maximum area of submatrix which has 1 in its each cell.\n\n# How do we calculate area?\n**$$Area = Length * breadth$$**\nIn this problem, we will calculate through **width** and **height**.\n\n**But wait, how to find the height \uD83E\uDD14?**\nWell, we have to find the height of those cells tha...
6
2
['C++']
2
largest-submatrix-with-rearrangements
[C++] ✅ Histogram Max Area Finding Problem || Count ones and sort
c-histogram-max-area-finding-problem-cou-zfrs
Approach:\n\nImagine each column in the matrix as a vertical bar, where its height represents the count of consecutive ones above it, including itself.\n\nIt is
anupam8nith
NORMAL
2023-11-26T09:22:31.151474+00:00
2023-11-27T15:16:02.418735+00:00
220
false
**Approach:**\n\nImagine each column in the matrix as a vertical bar, where its height represents the count of consecutive ones above it, including itself.\n\nIt is similar to **Histogram Area Finding Problem:** `Calculating the maximum area of a histogram for each row: This helps in determining the maximum rectangle t...
6
0
['C', 'Sorting']
2
largest-submatrix-with-rearrangements
C++||Largest Submatrix With Rearrangements to Largest Rectangle in Histogram||logic explained
clargest-submatrix-with-rearrangements-t-4wda
Simple conversion from Largest Submatrix With Rearrangements to Largest Rectangle in Histogram\nIdea:\n\n1.for each a[i][j] cell count number of continuos 1\'s
tejpratapp468
NORMAL
2021-01-17T04:06:47.385130+00:00
2021-01-20T07:20:56.835425+00:00
387
false
**Simple conversion from Largest Submatrix With Rearrangements to Largest Rectangle in Histogram\nIdea:**\n\n1.for each a[i][j] cell count number of continuos 1\'s in its column,so we have column height of a[i][j];\n2.for each row we will sort the row in descending order of column heights since you are allowed to rear...
6
0
[]
2
largest-submatrix-with-rearrangements
Simple C++ solution || TC: O(nmlog(m)) || SC:O(1)
simple-c-solution-tc-onmlogm-sco1-by-zee-6k7k
Intuition\nThis code finds the largest submatrix with all 1s in a binary matrix. It first transforms the matrix to represent the height of \'buildings\' of 1s.
Zeeshan_2512
NORMAL
2023-11-26T02:31:25.136786+00:00
2023-11-26T02:31:25.136807+00:00
936
false
# Intuition\nThis code finds the largest submatrix with all 1s in a binary matrix. It first transforms the matrix to represent the height of \'buildings\' of 1s. Then, for each row, it calculates the maximum area of the rectangle that can be formed using the \'building\' at each cell as the shortest \'building\'. The m...
5
0
['C++']
1
largest-submatrix-with-rearrangements
Python solution easy-understanding with comments
python-solution-easy-understanding-with-p2x9c
class Solution:\n\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n row, col = len(matrix), len(matrix[0])\n for j in range(col):
flyingspa
NORMAL
2021-04-12T09:29:09.989971+00:00
2021-04-12T09:29:09.990002+00:00
608
false
class Solution:\n\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n row, col = len(matrix), len(matrix[0])\n for j in range(col): # calculate the prefix consecutive one for each column \n for i in range(1,row):\n if matrix[i][j]:\n matrix[i][j]...
5
0
['Python']
0
largest-submatrix-with-rearrangements
Python solution: Largest Rectangular Area in a Rearrangable Histogram
python-solution-largest-rectangular-area-ib1f
\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n def largestRectangleArea(heights):\n heights.sort(reverse=True)\n
otoc
NORMAL
2021-01-17T04:06:22.620016+00:00
2021-01-17T04:07:56.980001+00:00
402
false
```\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n def largestRectangleArea(heights):\n heights.sort(reverse=True)\n res = heights[0]\n for i in range(1, len(heights)):\n res = max(res, heights[i] * (i + 1))\n return res\n \n ...
5
0
[]
0
largest-submatrix-with-rearrangements
Easy explained with best approach|| C++||greedy
easy-explained-with-best-approach-cgreed-ng4b
Intuition\nIntution is the precomputation of cells find the height for every column in the subsequent array.Then sorting of row according in non decreasing orde
dev_ved
NORMAL
2023-11-26T06:11:44.526081+00:00
2023-11-26T06:11:44.526112+00:00
770
false
# Intuition\nIntution is the precomputation of cells find the height for every column in the subsequent array.Then sorting of row according in non decreasing order and calculating the area since the cell number would provide the height and take width for subsequent column.\n\n# Approach\n1.precomputation\n2. for any ro...
4
0
['Math', 'Greedy', 'Sorting', 'Matrix', 'C++']
0
largest-submatrix-with-rearrangements
✅ Beats 96.02% 🚀 c++ code 🔥
beats-9602-c-code-by-omar_walied_ismail-gqz8
Intuition\n- I need all indexes in result matrix with only ones.\n\n# Approach\n- Save for everyone in the matrix, the number of consecutive ones before it.\n-
omar_walied_ismail
NORMAL
2023-11-26T05:26:19.032101+00:00
2023-11-26T05:26:19.032131+00:00
305
false
# Intuition\n- I need all indexes in result matrix with only ones.\n\n# Approach\n- Save for everyone in the matrix, the number of consecutive ones before it.\n- Take these numbers and sort it in ascending order. \n- Iterate on these numbers from back to front to get the greater high every time.\n- Take the minimum eve...
4
0
['Math', 'Dynamic Programming', 'Sorting', 'Matrix', 'C++']
3
largest-submatrix-with-rearrangements
🚀😎 BEATS 100% | MOST EASY APPROACH🔥🔥| C++ | JAVA | PYTHON | JS
beats-100-most-easy-approach-c-java-pyth-bn2s
Intuition\nUPVOTE IF YOU FOUND THIS HELPFUL !!\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n\n\n Describe your approach to solvi
The_Eternal_Soul
NORMAL
2023-11-26T02:48:04.202426+00:00
2023-11-26T02:48:04.202459+00:00
995
false
# Intuition\nUPVOTE IF YOU FOUND THIS HELPFUL !!\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n![Screenshot 2023-11-26 081330.png](https://assets.leetcode.com/users/images/53e71c26-9983-4dbf-9fef-2ca7b5cb1e6d_1700966821.6870956.png)\n\n<!-- Describe your approach to solving the pro...
4
0
['Array', 'Greedy', 'C', 'Sorting', 'Matrix', 'Python', 'C++', 'Java', 'JavaScript']
2
largest-submatrix-with-rearrangements
Walkthrough of the general algorithm
walkthrough-of-the-general-algorithm-by-bluh5
Just my notes of a walkthrough of the general algorithm people used to solve this question, hope this helps\n\n\n\t/\n * 1. Precalculate the # of consecutiv
qmscorp
NORMAL
2021-07-14T01:35:33.985759+00:00
2021-07-14T01:35:33.985792+00:00
283
false
Just my notes of a walkthrough of the general algorithm people used to solve this question, hope this helps\n\n\n\t/**\n * 1. Precalculate the # of consecutive ones (vertically) in the matrix,\n * --> which we are actually calculating the height of each column/histogram\n *\n * [0,0,1] [0,0,1]\n...
4
0
[]
1
largest-submatrix-with-rearrangements
[Python3] Faster than 100% - Easy [Explanation + Comments]
python3-faster-than-100-easy-explanation-1sqc
The core logic of my program is :\nFor any cell (i,j) for all cells in the same row store the number of ones starting from that row.\nFor example, matrix = [[0,
mihirrane
NORMAL
2021-01-17T04:36:26.540213+00:00
2021-01-17T19:07:51.760750+00:00
485
false
The core logic of my program is :\nFor any cell (i,j) for all cells in the same row store the number of ones starting from that row.\nFor example, matrix = [[0,0,1],[1,1,1],[1,0,1]]\nCorresponding map (d) = {1: [2,1,2], 2: [1,1], 0: [3]}\nExplanation of map: \nKey corresponds to the row number. \nLet\'s look at row num...
4
0
['Python', 'Python3']
1
largest-submatrix-with-rearrangements
🚀✅🚀 Beats 101% -1727. Largest Submatrix With Rearrangements
beats-101-1727-largest-submatrix-with-re-dxqz
Example Explanation\nLet\'s break down the process step by step using an example matrix:\n\nExample Matrix:\n\n[\n [0, 0, 1],\n [1, 1, 1],\n [1, 0, 1]\n]\n\nSte
arshbhatia1551
NORMAL
2023-11-26T10:28:13.772766+00:00
2023-11-26T10:28:13.772799+00:00
158
false
**Example Explanation**\nLet\'s break down the process step by step using an example matrix:\n\n**Example Matrix:**\n```\n[\n [0, 0, 1],\n [1, 1, 1],\n [1, 0, 1]\n]\n```\n**Step 1: Preprocessing**\n```\n[\n [0, 0, 1],\n [1, 1, 2],\n [2, 0, 3]\n]\n```\nFor each cell matrix[i][j] = 1, update it with the height of consecu...
3
0
['Array', 'Greedy', 'C', 'Sorting', 'Matrix', 'Python', 'Java', 'JavaScript']
0
largest-submatrix-with-rearrangements
O(N*M*LogM)
onmlogm-by-3s_akb-3w04
\n# Code\n\npublic class Solution {\n public int LargestSubmatrix(int[][] matrix) {\n int Y = matrix.Length; //rows count\n int X = matrix[0
3S_AKB
NORMAL
2023-07-31T20:23:12.380373+00:00
2023-07-31T20:23:12.380392+00:00
47
false
\n# Code\n```\npublic class Solution {\n public int LargestSubmatrix(int[][] matrix) {\n int Y = matrix.Length; //rows count\n int X = matrix[0].Length; //columns count\n\n //transform matrix to (matrix[y][x] = count of 1s upper (<y))\n for (int x = 0; x < X; x++) \n ...
3
0
['C#']
1
largest-submatrix-with-rearrangements
C++ | Variation of Leetcode 85.Maximal Rectangle
c-variation-of-leetcode-85maximal-rectan-7l5z
\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& v) {\n int n=v.size();\n int m=v[0].size();\n int res;\n
GeekyBits
NORMAL
2022-10-10T12:55:49.812259+00:00
2022-10-10T12:55:49.812363+00:00
469
false
```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& v) {\n int n=v.size();\n int m=v[0].size();\n int res;\n vector<int> vv(m,0);\n for(int i=0;i<n;i++){\n for(int j=0;j<m;j++){\n if(v[i][j]==1){\n vv[j]+=1;\n ...
3
0
[]
0
largest-submatrix-with-rearrangements
C++ Solution | O(m * n * logn)
c-solution-om-n-logn-by-horcrux903-mzvd
\nclass Solution {\npublic:\n\n\tint largestSubmatrix(vector<vector<int>>& a)\n\t{\n\t\tint ans = 0;\n\t\tint n = a.size(), m = a[0].size();\n\n\t\tint tmp[m];\
horcrux903
NORMAL
2022-01-04T19:01:27.881769+00:00
2022-01-04T19:01:27.881814+00:00
150
false
```\nclass Solution {\npublic:\n\n\tint largestSubmatrix(vector<vector<int>>& a)\n\t{\n\t\tint ans = 0;\n\t\tint n = a.size(), m = a[0].size();\n\n\t\tint tmp[m];\n\t\tmemset(tmp, 0, sizeof(tmp));\n\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tvector<int> v;\n\n\t\t\tfor (int j = 0; j < m; j++)\n\t\t\t{\n\t\t\t\tif (...
3
0
['Sorting']
0
largest-submatrix-with-rearrangements
Easy C++ solution || commented
easy-c-solution-commented-by-saiteja_bal-j505
\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n \n //for every column keep a track of number of consecutive
saiteja_balla0413
NORMAL
2021-07-05T16:32:23.619671+00:00
2021-07-05T16:32:23.619704+00:00
349
false
```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n \n //for every column keep a track of number of consecutive ones upto the index\n int m=matrix.size();\n int n=matrix[0].size();\n for(int j=0;j<n;j++)\n {\n for(int i=0;i<m;i++...
3
0
['C']
0
largest-submatrix-with-rearrangements
Java Priority Queue Solution
java-priority-queue-solution-by-mayank_p-op8i
https://achievementguru.com/leetcode-1727-largest-submatrix-with-rearrangements-java-solution/\n\nclass Solution {\n public int largestSubmatrix(int[][] matr
mayank_pratap
NORMAL
2021-01-18T08:24:18.300532+00:00
2021-01-18T08:25:20.941304+00:00
538
false
https://achievementguru.com/leetcode-1727-largest-submatrix-with-rearrangements-java-solution/\n```\nclass Solution {\n public int largestSubmatrix(int[][] matrix) {\n //Store matrix[i][j]= total number of consecutive 1s along column j ending at index (i,j).\n for(int i=1;i<matrix.length;i++) //Start...
3
0
['Heap (Priority Queue)', 'Java']
0
largest-submatrix-with-rearrangements
My Java Solution with small explanation 1) Count the 1's in column 2) Sort the rows and count
my-java-solution-with-small-explanation-iy26l
\nclass Solution {\n public int largestSubmatrix(int[][] matrix) {\n // count number of 1 in each column and update it\n int row = matrix.lengt
vrohith
NORMAL
2021-01-18T05:06:40.617611+00:00
2021-01-18T05:06:40.617696+00:00
380
false
```\nclass Solution {\n public int largestSubmatrix(int[][] matrix) {\n // count number of 1 in each column and update it\n int row = matrix.length;\n int col = matrix[0].length;\n int count = 0;\n for (int i=1; i<row; i++) {\n for (int j=0; j<col; j++) {\n ...
3
0
['Sorting', 'Matrix', 'Java']
1
largest-submatrix-with-rearrangements
C# - Sorting by heights to get max area
c-sorting-by-heights-to-get-max-area-by-0mzex
csharp\npublic int LargestSubmatrix(int[][] matrix)\n{\n\tint[] heights = new int[matrix[0].Length];\n\tint result = 0;\n\n\tfor (int row = 0; row < matrix.Leng
christris
NORMAL
2021-01-18T02:39:14.126668+00:00
2021-01-18T02:39:14.126695+00:00
94
false
```csharp\npublic int LargestSubmatrix(int[][] matrix)\n{\n\tint[] heights = new int[matrix[0].Length];\n\tint result = 0;\n\n\tfor (int row = 0; row < matrix.Length; row++)\n\t{\n\t\tfor (int column = 0; column < matrix[0].Length; column++)\n\t\t{\n\t\t\tif (matrix[row][column] == 0)\n\t\t\t{\n\t\t\t\theights[column] ...
3
0
[]
0
largest-submatrix-with-rearrangements
16 line Python solution (998ms)
16-line-python-solution-998ms-by-15sawye-psck
Intuition\n Describe your first thoughts on how to solve this problem. \nIterate over rows while keeping track of the height of columns of 1\'s above the row. S
15sawyer
NORMAL
2023-11-26T20:04:44.982906+00:00
2023-11-26T20:46:36.465858+00:00
425
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIterate over rows while keeping track of the height of columns of 1\'s above the row. Sort the heights after each iteration and check the area of all possible rectangles that would fit into the graph of heights.\n# Approach\n<!-- Describe...
2
0
['Python3']
1
largest-submatrix-with-rearrangements
✅☑[C++/Java/Python/JavaScript] || 3 Approaches || EXPLAINED🔥
cjavapythonjavascript-3-approaches-expla-szh1
PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n# Approaches\n(Also explained in the code)\n\n#### Approach 1(Sort By Height On Each Baseline Row)\n1. Matrix traversal:\
MarkSPhilip31
NORMAL
2023-11-26T19:40:48.424908+00:00
2023-11-26T19:40:48.424930+00:00
231
false
# PLEASE UPVOTE IF IT HELPED\n\n---\n\n\n# Approaches\n**(Also explained in the code)**\n\n#### ***Approach 1(Sort By Height On Each Baseline Row)***\n1. **Matrix traversal:**\n - The code iterates through each row of the matrix.\n1. **Accumulating consecutive ones:**\n - For each non-zero element in the matrix (...
2
0
['Array', 'Greedy', 'C', 'Sorting', 'Matrix', 'C++', 'Java', 'Python3', 'JavaScript']
1
largest-submatrix-with-rearrangements
One line solution. Runtime 100%!!!
one-line-solution-runtime-100-by-xxxxkav-7cnp
\n\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n return max(max(map(mul, sorted(row, reverse = True), count(1))) fo
xxxxkav
NORMAL
2023-11-26T13:56:13.945467+00:00
2023-11-26T13:56:13.945501+00:00
98
false
![\u0421\u043D\u0438\u043C\u043E\u043A \u044D\u043A\u0440\u0430\u043D\u0430 2023-11-26 \u0432 16.55.31.png](https://assets.leetcode.com/users/images/aec4765b-f086-4771-9953-fb62db621aea_1701006958.9566693.png)\n```\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n return max(max...
2
0
['Python3']
0
largest-submatrix-with-rearrangements
C# Solution for Largest Submatrix With Rearrangements Problem
c-solution-for-largest-submatrix-with-re-qveu
Intuition\n Describe your first thoughts on how to solve this problem. \nThis solution maintains a count of consecutive 1s vertically in the input matrix and th
Aman_Raj_Sinha
NORMAL
2023-11-26T11:32:19.495160+00:00
2023-11-26T11:32:19.495189+00:00
46
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis solution maintains a count of consecutive 1s vertically in the input matrix and then sorts each row to find the maximum area of the submatrix containing only 1s after rearranging the columns optimally.\n\n# Approach\n<!-- Describe yo...
2
0
['C#']
0
largest-submatrix-with-rearrangements
C++ | Simple Code | Beats 85.23% of users with C++
c-simple-code-beats-8523-of-users-with-c-hw63
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Ankita2905
NORMAL
2023-11-26T11:11:14.344781+00:00
2023-11-26T11:11:14.344808+00:00
26
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
largest-submatrix-with-rearrangements
Easy C++ || O(m*n) solution
easy-c-omn-solution-by-jpank1983-b1vk
Intuition\n Describe your first thoughts on how to solve this problem. \nThis is similar problem to Largest Rectangle in Histogram. We just need to find height
jPank1983
NORMAL
2023-11-26T10:59:16.385405+00:00
2023-11-26T16:00:44.627777+00:00
25
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThis is similar problem to Largest Rectangle in Histogram. We just need to find height of every column through every row taking every row as base.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe hight of every co...
2
0
['C++']
0
largest-submatrix-with-rearrangements
Beats 95% simple prefix sum like solution
beats-95-simple-prefix-sum-like-solution-l9k3
Intuition\n Describe your first thoughts on how to solve this problem. \ncount the continuous ones on each column for each row and sort them in descending order
rk_ninjaa__404
NORMAL
2023-11-26T10:28:17.733239+00:00
2023-11-26T10:28:17.733256+00:00
259
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\ncount the continuous ones on each column for each row and sort them in descending order so that the first column contains the most number of continuous ones. Sorting so that we can align the ones continuously to make it a submatrix. \n\n*...
2
0
['Greedy', 'Sorting', 'Prefix Sum', 'C++']
2
largest-submatrix-with-rearrangements
Java Beginner Friendly Code
java-beginner-friendly-code-by-ritikranj-dx2g
Explanation\n Describe your first thoughts on how to solve this problem. \nStep 1: Preprocessing (as given is Hint 1)\nStep 2: Sorting Rows (as given in Hint 2)
ritikranjan12
NORMAL
2023-11-26T09:16:00.444249+00:00
2023-11-26T09:16:00.444272+00:00
156
false
# Explanation\n<!-- Describe your first thoughts on how to solve this problem. -->\nStep 1: Preprocessing (as given is Hint 1)\nStep 2: Sorting Rows (as given in Hint 2)\nStep 3: Calculate Area\nIterate through each row and calculate the area for each cell.\n\n# Complexity\n- Time complexity: O(matrix.length * matrix[0...
2
0
['Array', 'Math', 'Sorting', 'Java']
1
largest-submatrix-with-rearrangements
[C] Sorting
c-sorting-by-leetcodebug-653t
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
leetcodebug
NORMAL
2023-11-26T05:30:14.013214+00:00
2023-11-26T05:30:14.014825+00:00
101
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(m * nlogn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(m * n)$$\n<!-- Add your space com...
2
0
['Array', 'Greedy', 'C', 'Sorting', 'Matrix']
1
largest-submatrix-with-rearrangements
Python3 Solution
python3-solution-by-motaharozzaman1996-63xv
\n\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n row=len(matrix)\n col=len(matrix[0])\n ans=0\n
Motaharozzaman1996
NORMAL
2023-11-26T03:00:50.325226+00:00
2023-11-26T03:00:50.325247+00:00
904
false
\n```\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n row=len(matrix)\n col=len(matrix[0])\n ans=0\n for r in range(1,row):\n for c in range(col):\n matrix[r][c]+=matrix[r-1][c] if matrix[r][c] else 0\n\n for r in range(row...
2
0
['Python', 'Python3']
0
largest-submatrix-with-rearrangements
✅ Swift: Easy to Understand and Simple Solution
swift-easy-to-understand-and-simple-solu-o52v
Complexity\n- Time complexity: O(mn.log.n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \
sohagkumarbiswas
NORMAL
2023-11-26T02:58:08.454603+00:00
2023-11-26T02:58:08.454620+00:00
26
false
# Complexity\n- Time complexity: $$O(mn.log.n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n func largestSubmatrix(_ matrix: [[Int]]) -> Int {\n var ans = 0\n var hist =...
2
0
['Array', 'Greedy', 'Swift', 'Sorting', 'Matrix']
0
largest-submatrix-with-rearrangements
O(m*n*log(n)) Solution ||
omnlogn-solution-by-yashmenaria-asju
Complexity\n- Time complexity:O(mnlog(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n#
yashmenaria
NORMAL
2023-11-26T02:55:51.379392+00:00
2023-11-26T02:55:51.379411+00:00
16
false
# Complexity\n- Time complexity:O(m*n*log(n))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n# Code\n# C++\n```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n for (int i = 0; i < mat...
2
0
['Array', 'Greedy', 'Sorting', 'Matrix', 'C++', 'Java']
0
largest-submatrix-with-rearrangements
C# || Solution with LINQ
c-solution-with-linq-by-vdmhunter-k3a3
Code\n\npublic class Solution\n{\n public int LargestSubmatrix(int[][] matrix)\n {\n for (var i = 1; i < matrix.Length; i++)\n for (var
vdmhunter
NORMAL
2023-11-26T00:15:51.511349+00:00
2023-11-26T00:15:51.511375+00:00
83
false
# Code\n```\npublic class Solution\n{\n public int LargestSubmatrix(int[][] matrix)\n {\n for (var i = 1; i < matrix.Length; i++)\n for (var j = 0; j < matrix[0].Length; j++)\n if (matrix[i][j] == 1)\n matrix[i][j] = matrix[i - 1][j] + 1;\n\n return matri...
2
1
['C#']
0
largest-submatrix-with-rearrangements
Simple greedy approach || Not a medium level question probably hard one 🤨
simple-greedy-approach-not-a-medium-leve-3s21
\nclass Solution\n{\n public:\n int largestSubmatrix(vector<vector < int>> &mat)\n {\n int m = mat.size();\n int n = mat[
Tan_B
NORMAL
2023-04-19T06:34:01.517736+00:00
2023-04-19T06:34:01.517779+00:00
121
false
```\nclass Solution\n{\n public:\n int largestSubmatrix(vector<vector < int>> &mat)\n {\n int m = mat.size();\n int n = mat[0].size();\n vector<int> h(n, 0);//array for counting height at each level.\n vector<int> x;\n int ans = 0;\n for...
2
0
['Math', 'Greedy', 'C', 'Sorting']
0
largest-submatrix-with-rearrangements
C++ using 2 traversals by Sorting
c-using-2-traversals-by-sorting-by-divya-axhg
\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& mat) {\n int m= mat.size();\n int n= mat[0].size();\n for(int i=
divyanshugupta5901
NORMAL
2022-07-16T15:18:10.110353+00:00
2022-07-16T15:18:10.110396+00:00
373
false
```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& mat) {\n int m= mat.size();\n int n= mat[0].size();\n for(int i=1; i<m ; i++){\n for(int j=0; j<n; j++){\n if(mat[i][j]!=0)\n mat[i][j]+= mat[i-1][j];\n }\n ...
2
0
['C']
0
largest-submatrix-with-rearrangements
Java solution with approach
java-solution-with-approach-by-soumya00-ad17
Approach:\n\n1. Traverse the matrix column wise\n2. For every column, calculate the continuous running sum and update the array itself. If any cell value is 0,
soumya00
NORMAL
2022-07-16T04:57:22.723395+00:00
2022-07-16T04:57:22.723452+00:00
186
false
**Approach:**\n\n1. Traverse the matrix column wise\n2. For every column, calculate the continuous running sum and update the array itself. If any cell value is 0, reset the continuous sum to 0\n3. Next traverse the matrix row wise, and sort every row in decsending order\n4. Calculate the maximum area greedily and stor...
2
0
['Greedy', 'Sorting', 'Simulation']
0
largest-submatrix-with-rearrangements
✅✅Faster || Easy To Understand || C++ Code
faster-easy-to-understand-c-code-by-__kr-vkrf
This Problem is like Maximum Rectangle In Histogram\n\n Using Sorting\n\n Time Complexity :- O(N * M * logM)\n\n Space Complexity :- O(M)*\n\n\nclass Solution {
__KR_SHANU_IITG
NORMAL
2022-07-15T05:59:26.285714+00:00
2022-07-15T05:59:26.285778+00:00
301
false
* ***This Problem is like Maximum Rectangle In Histogram***\n\n* ***Using Sorting***\n\n* ***Time Complexity :- O(N * M * logM)***\n\n* ***Space Complexity :- O(M)***\n\n```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n \n int n = matrix.size();\n \n i...
2
0
['C', 'Sorting', 'C++']
0
largest-submatrix-with-rearrangements
Java | Basic Math + Intuitive
java-basic-math-intuitive-by-dz_adman-83wf
Approach:\nJust use basic math for AreaOfRectangle = height * width\nNow all we need is height and width for each cell while calculating area (that cell being t
dz_adman
NORMAL
2022-06-27T11:10:47.002769+00:00
2022-06-27T11:10:47.002832+00:00
169
false
**Approach**:\nJust use basic math for **AreaOfRectangle = height * width**\nNow all we need is **height and width for each cell while calculating area** (that cell being the bottom right end of the rectangle being considered)\n\nThis can be done in following 2 major steps:\n1. Modify matrix values to keep track of max...
2
0
['Math']
0
largest-submatrix-with-rearrangements
Python O(MN log N) with comments
python-omn-log-n-with-comments-by-vsavki-ais3
\nfrom collections import Counter\n\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n M = len(matrix)\n N = len(
vsavkin
NORMAL
2021-06-06T11:37:43.750437+00:00
2021-06-06T11:37:43.750483+00:00
290
false
```\nfrom collections import Counter\n\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n M = len(matrix)\n N = len(matrix[0])\n \n colcons = [] # preprocess columns\n for c in range(N):\n cons = []\n s = 0\n for r in r...
2
0
['Sorting', 'Python']
0
largest-submatrix-with-rearrangements
SIMPLE SOLUTION 6MS FASTER THAN 100%
simple-solution-6ms-faster-than-100-by-s-n4us
JAVA CODE IS:\n# \n\nclass Solution {\n int find(int arr[]){\n Arrays.sort(arr);\n int res=0;\n for(int i=0;i<arr.length;i++)\n
shivam_gupta_
NORMAL
2021-03-18T06:51:03.900907+00:00
2021-03-18T06:51:03.900938+00:00
143
false
JAVA CODE IS:\n# \n```\nclass Solution {\n int find(int arr[]){\n Arrays.sort(arr);\n int res=0;\n for(int i=0;i<arr.length;i++)\n res=Math.max(res,arr[i]*(arr.length-i));\n return res;\n }\n public int largestSubmatrix(int[][] matrix) {\n //size of matrix is n*...
2
0
[]
1
largest-submatrix-with-rearrangements
[Python] prefix sum, sort rows, compute areas - O(m*nlogn) runtime - with explanation
python-prefix-sum-sort-rows-compute-area-ugi4
\nApproach: O(m\*nlogn) runtime O(1) space - 1116ms (97.79%), 40.7MB (47.17%)\nCompute prefix from top to bottom. Reset everytime we reach a 0.\nNow go to each
vikktour
NORMAL
2021-01-23T17:41:24.036855+00:00
2024-09-27T23:03:53.442573+00:00
444
false
\nApproach: O(m\\*nlogn) runtime O(1) space - 1116ms (97.79%), 40.7MB (47.17%)\nCompute prefix from top to bottom. Reset everytime we reach a 0.\nNow go to each row and compute area for each value (starting from right to left). For each value, we will use all values to the right of it (including itself) to compute area...
2
0
['Sorting', 'Prefix Sum', 'Python', 'Python3']
1
largest-submatrix-with-rearrangements
Java Solution | O(m * n * logn) time complexity
java-solution-om-n-logn-time-complexity-glk55
\nclass Solution {\n public int largestSubmatrix(int[][] matrix) {\n \n int m = matrix.length;\n int n = matrix[0].length;\n \n
vishal_sherawat
NORMAL
2021-01-21T08:08:08.959956+00:00
2023-11-26T07:02:40.747236+00:00
337
false
```\nclass Solution {\n public int largestSubmatrix(int[][] matrix) {\n \n int m = matrix.length;\n int n = matrix[0].length;\n \n for(int i = 1; i < m; i++){\n \n for(int j = 0; j < n; j++){\n \n if(matrix[i][j] == 1){\n ...
2
0
['Java']
0
largest-submatrix-with-rearrangements
O(n^2log(n)) 100% better time complexity[C++}
on2logn-100-better-time-complexityc-by-a-tcy3
Detail Description Is In Code Itself\nIf You like My Code Then Please Upvot\n\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix)
anil111
NORMAL
2021-01-18T04:46:23.777348+00:00
2021-01-18T04:54:08.598538+00:00
81
false
**Detail Description Is In Code Itself**\nIf You like My Code Then Please Upvot\n```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) \n {\n int row=matrix.size(),col=matrix[0].size();\n int sum[row][col];\n // calculate no of 1\'s continue in the column\n ...
2
0
[]
0
largest-submatrix-with-rearrangements
[Python] Clear Solution with Video Explanation
python-clear-solution-with-video-explana-wu53
Video with clear visualization and explanation:\nhttps://youtu.be/-YVsiCrbeRE\n\n\n\nIntuition: Largest rectangle in histogram with reversed sort\n\n\nCode\n\nc
iverson52000
NORMAL
2021-01-17T22:30:15.723926+00:00
2021-01-17T22:30:15.723955+00:00
237
false
Video with clear visualization and explanation:\nhttps://youtu.be/-YVsiCrbeRE\n\n\n\nIntuition: Largest rectangle in histogram with reversed sort\n\n\n**Code**\n```\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n n_r, n_c, res = len(matrix), len(matrix[0]), 0\n\n for r ...
2
0
['Python']
0
largest-submatrix-with-rearrangements
C++|| Implementation || DP used
c-implementation-dp-used-by-wargraver-cj0a
\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n int i,j,k,n,m,ct=0,ans=0;\n n=matrix.size();m=matrix[0].siz
wargraver
NORMAL
2021-01-17T05:34:02.737627+00:00
2021-01-17T05:34:02.737683+00:00
66
false
```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& matrix) {\n int i,j,k,n,m,ct=0,ans=0;\n n=matrix.size();m=matrix[0].size();\n int dp[n+5][m+5];\n for(j=0;j<m;j++){\n int flag=0,ct=0;\n for(i=n-1;i>=0;i--){\n if(matrix[i][j]==...
2
0
[]
0
largest-submatrix-with-rearrangements
SIMPLE SORT, beats 100% easy sorting solution
simple-sort-beats-100-easy-sorting-solut-qabw
`\nclass Solution {\npublic:\n int maxArea(vector<vector<int>> mat,int R,int C) \n{ \n \n vector<vector<int>> hist(R,vector<int> (C,0));\n \n for (i
rdas18246
NORMAL
2021-01-17T04:32:07.999880+00:00
2021-01-17T04:32:07.999917+00:00
61
false
````\nclass Solution {\npublic:\n int maxArea(vector<vector<int>> mat,int R,int C) \n{ \n \n vector<vector<int>> hist(R,vector<int> (C,0));\n \n for (int i = 0; i < C; i++) { \n \n hist[0][i] = mat[0][i]; \n \n \n for (int j = 1; j < R; j++) \n hist[j][i] = (mat[j][i] == 0) ? ...
2
0
[]
0
largest-submatrix-with-rearrangements
[Python] scanning row strategy
python-scanning-row-strategy-by-21eleven-6kb8
Make a scanning row (r) that you will compare with each row in the matrix. This scanning row tracks the "streak" for each column (how many previous rows had the
21eleven
NORMAL
2021-01-17T04:26:54.849160+00:00
2021-01-17T15:50:30.484596+00:00
148
false
Make a scanning row (`r`) that you will compare with each row in the matrix. This scanning row tracks the "streak" for each column (how many previous rows had the bit set in that column). If a row does has a zero for a column the scanning row at that column position gets reset to zero, otherwise the streak count at tha...
2
0
[]
1
largest-submatrix-with-rearrangements
Vertical Profiling with const input
vertical-profiling-with-const-input-by-m-unhm
Still a O(RC) but will less operations than required if modifying the matrix.Code
michelusa
NORMAL
2025-03-21T00:09:21.042536+00:00
2025-03-21T00:09:21.042536+00:00
4
false
Still a O(RC) but will less operations than required if modifying the matrix. # Code ```cpp [] class Solution { public: int largestSubmatrix(const std::vector<std::vector<int>>& matrix) { const size_t R = matrix.size(); const size_t C = matrix[0].size(); int max_area = 0; std::v...
1
0
['C++']
0
largest-submatrix-with-rearrangements
Best Solution | C++
best-solution-c-by-nssvaishnavi-pyq1
IntuitionTo solve this problem optimally, we need to make the best use of the column rearrangement to maximize the area of a submatrix consisting entirely of 1s
nssvaishnavi
NORMAL
2025-02-06T18:10:23.611413+00:00
2025-02-06T18:10:23.611413+00:00
21
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> To solve this problem optimally, we need to make the best use of the column rearrangement to maximize the area of a submatrix consisting entirely of 1s # Approach <!-- Describe your approach to solving the problem. --> We can treat each ro...
1
0
['C++']
0
largest-submatrix-with-rearrangements
In-place solutions, Beats >90%
in-place-solutions-beats-90-by-simolekc-sszb
Code
simolekc
NORMAL
2025-01-28T12:28:26.513215+00:00
2025-01-28T12:28:26.513215+00:00
6
false
# Code ```javascript [] /** * @param {number[][]} matrix * @return {number} */ var largestSubmatrix = function (matrix) { let n = matrix.length; let m = matrix[0].length; for (let i = 1; i < n; i++) { for (let j = 0; j < m; j++) { if (matrix[i][j]) matrix[i][j] += matrix[i - 1][j];...
1
0
['JavaScript']
0
largest-submatrix-with-rearrangements
Brute force solution
brute-force-solution-by-execrox-08cu
Code\n\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n m, n, ans = len(matrix), len(matrix[0]), 0\n \n
execrox
NORMAL
2024-04-26T19:10:16.666172+00:00
2024-04-26T19:10:57.843303+00:00
4
false
# Code\n```\nclass Solution:\n def largestSubmatrix(self, matrix: List[List[int]]) -> int:\n m, n, ans = len(matrix), len(matrix[0]), 0\n \n for j in range(n):\n for i in range(1, m):\n matrix[i][j] += matrix[i-1][j] if matrix[i][j] else 0\n \n for...
1
0
['Matrix', 'Python3']
1
largest-submatrix-with-rearrangements
Easyest way to Largest Submatrix With Rearrangements.
easyest-way-to-largest-submatrix-with-re-7bkb
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
saslo0165
NORMAL
2023-11-27T13:42:13.188207+00:00
2023-11-27T13:42:13.188243+00:00
21
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Dart']
0
largest-submatrix-with-rearrangements
[JS] DP (w/Explanation) | Beats 90.91% & 72.73%
js-dp-wexplanation-beats-9091-7273-by-ja-hxuh
Intuition\nUpon encountering this problem, the first idea is to maximize the area of 1s in a binary matrix by rearranging the columns. A key realization is that
jamesBaxtuh
NORMAL
2023-11-26T22:30:30.563077+00:00
2023-11-28T00:59:25.049087+00:00
5
false
# Intuition\nUpon encountering this problem, the first idea is to maximize the area of 1s in a binary matrix by rearranging the columns. A key realization is that we can count the number of 1s in each column and then sort these counts row by row. This sorting effectively simulates rearranging the columns so that rows w...
1
0
['Dynamic Programming', 'Greedy', 'Sorting', 'Matrix', 'JavaScript']
0
largest-submatrix-with-rearrangements
Easy Solution - Ashutosh Kumar
easy-solution-ashutosh-kumar-by-ak180920-zq2v
Intuition\nThe basic intuition to solve this question is first see that we can only swap columns. This means the vertical order of the 1s doesn\'t change. \n\n#
ak18092000
NORMAL
2023-11-26T20:57:44.076189+00:00
2023-11-26T20:57:44.076230+00:00
45
false
# Intuition\nThe basic intuition to solve this question is first see that we can only swap columns. This means the vertical order of the 1s doesn\'t change. \n\n# Approach\nWe calculate the no. of consecutive 1s vertically in each row and update the elements according to that. The count resets to 0 whenever we encounte...
1
0
['C++']
0
largest-submatrix-with-rearrangements
Sorting + expand consecutive 1s || Faster than 96% || O(n*m*m) || Clean Java Code
sorting-expand-consecutive-1s-faster-tha-hgds
Complexity\n- Time complexity: O(nmm)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n#
youssef1998
NORMAL
2023-11-26T18:38:58.045329+00:00
2023-11-26T18:38:58.045353+00:00
132
false
# Complexity\n- Time complexity: $$O(n*m*m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int largestSubmatrix(int[][] matrix) {\n int maxArea = 0, n = matrix.length, m ...
1
0
['Sorting', 'Java']
0
largest-submatrix-with-rearrangements
Beats 100.00% of users with Python in runtime and memory
beats-10000-of-users-with-python-in-runt-hfmp
Approach\nUsing dynamic programming to calculate the height of each column, representing the number of consecutive ones ending at that column.\nThen sorting the
anushkaTonk
NORMAL
2023-11-26T17:58:21.400679+00:00
2023-11-26T17:58:21.400701+00:00
17
false
# Approach\nUsing dynamic programming to calculate the height of each column, representing the number of consecutive ones ending at that column.\nThen sorting the columns based on their height.\nThen, calculating the maximum area of the submatrix containing only ones.\n\n# Complexity\n- Time complexity:\nO(m * n * log(...
1
0
['Python']
0
largest-submatrix-with-rearrangements
Unique solution || bests 100% || Well Expalined and easy to understand
unique-solution-bests-100-well-expalined-pm6s
\n# Approach\n\n\n1. Iterate through the matrix, updating each element to represent the height of consecutive 1s above it.\n2. Sort the heights of each row in a
DeepakVrma
NORMAL
2023-11-26T17:46:53.528418+00:00
2023-11-26T17:46:53.528447+00:00
160
false
\n# Approach\n\n\n1. Iterate through the matrix, updating each element to represent the height of consecutive 1s above it.\n2. Sort the heights of each row in ascending order.\n3. Iterate through each row, calculating the area for each height and width combination, updating the maximum area encountered.\n4. Return the ...
1
0
['Sorting', 'C++']
2
largest-submatrix-with-rearrangements
Java Easiest Solution
java-easiest-solution-by-shivansu_7-mstk
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Shivansu_7
NORMAL
2023-11-26T17:30:40.895917+00:00
2023-11-26T17:30:40.895948+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Java']
0
largest-submatrix-with-rearrangements
Java 100% Efficient code || comment line by line understable
java-100-efficient-code-comment-line-by-d3aux
\n\n# Code\n```\nclass Solution\n {\n \n // Function to find the size of the largest submatrix containing only 1s\n \n public int largestSubmatrix(int[][] m
Dheerajkumar9631r
NORMAL
2023-11-26T16:36:24.904666+00:00
2023-11-26T16:37:41.659803+00:00
12
false
\n\n# Code\n```\nclass Solution\n {\n \n // Function to find the size of the largest submatrix containing only 1s\n \n public int largestSubmatrix(int[][] matrix) {\n // Get the number of rows and columns in the matrix\n \n int m = matrix.length;\n int n = matrix[0].length;\n \n //...
1
0
['Java']
0
largest-submatrix-with-rearrangements
Easy Python Solution - Beats 100%
easy-python-solution-beats-100-by-u_day-aclb
Intuition\nThe problem requires finding the largest submatrix within the given matrix, where every element of the submatrix is 1, after reordering the columns o
U_day
NORMAL
2023-11-26T16:35:16.210907+00:00
2023-11-26T16:35:16.210932+00:00
22
false
# Intuition\nThe problem requires finding the largest submatrix within the given matrix, where every element of the submatrix is 1, after reordering the columns optimally.\n# Approach\n- Initialize variables m and n to store the number of rows and columns in the matrix, respectively.\n- Iterate over the matrix from the...
1
0
['Python']
0
largest-submatrix-with-rearrangements
Dynamic programming approach
dynamic-programming-approach-by-tanmaybh-60b3
\n# Approach\n Describe your approach to solving the problem. \nThe current approach iterates over each row and column, updating the matrix values and then sort
tanmaybhujade
NORMAL
2023-11-26T16:08:43.137775+00:00
2023-11-26T16:08:43.137803+00:00
7
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe current approach iterates over each row and column, updating the matrix values and then sorting for each row. To make it more efficient, we can keep track of the height of consecutive ones for each cell in a separate array. This eliminates the n...
1
0
['Java']
0
largest-submatrix-with-rearrangements
213ms Beats 100.00%of users with C
213ms-beats-10000of-users-with-c-by-salm-05zi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nHistogram Calculation:\
SalmaHisham
NORMAL
2023-11-26T14:26:53.376547+00:00
2023-11-26T14:26:53.376569+00:00
14
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**Histogram Calculation:**\nFor each element in the matrix, the algorithm computes the height of the column up to that element by accumulating the consecutive occurren...
1
0
['C']
0
largest-submatrix-with-rearrangements
Runtime 100% | Intuitive aproach
runtime-100-intuitive-aproach-by-user876-70no
Approach\n Describe your approach to solving the problem. \nFor each cell in column we count how long streak of 1 is above them.\n\nThen we are checking row by
user8764IR
NORMAL
2023-11-26T13:01:33.486547+00:00
2023-11-26T13:01:33.486572+00:00
86
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nFor each cell in column we count how long streak of `1` is above them.\n\nThen we are checking row by row, how we can replace columns so they will form the best submatrix of `1` -> we can acomplish it by sorting the row. \nNow we need to check which c...
1
0
['Java']
0
largest-submatrix-with-rearrangements
Ruby || O(m*n*log(n))/O(1)
ruby-omnlogno1-by-alecn2002-k3az
\n# Complexity\n- Time complexity:\nO(mnlog(n))\n\n- Space complexity:\nO(1)\n\n# Code\nruby\nclass Numeric\n def max(v) = (self < v ? v : self)\nend\n\ndef
alecn2002
NORMAL
2023-11-26T12:00:35.236982+00:00
2023-11-26T12:00:35.237015+00:00
7
false
\n# Complexity\n- Time complexity:\n$$O(m*n*log(n))$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```ruby\nclass Numeric\n def max(v) = (self < v ? v : self)\nend\n\ndef largest_submatrix(matrix)\n h, w = matrix.size, matrix.first.size\n matrix.each_cons(2).inject(matrix.first.filter(&:positive?).size) {|res, ...
1
0
['Ruby']
0
largest-submatrix-with-rearrangements
accumulate the height
accumulate-the-height-by-mr_stark-uvd6
\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& mt) {\n \n int n = mt.size();\n int m = mt[0].size();\n int r
mr_stark
NORMAL
2023-11-26T11:52:07.968869+00:00
2023-11-26T11:52:38.401563+00:00
23
false
```\nclass Solution {\npublic:\n int largestSubmatrix(vector<vector<int>>& mt) {\n \n int n = mt.size();\n int m = mt[0].size();\n int res = 0;\n for(int i = 0;i<n;i++)\n {\n for(int j=0;j<m;j++)\n {\n if(mt[i][j] == 1 && i>0)\n ...
1
0
['C']
0
largest-submatrix-with-rearrangements
Swift solution
swift-solution-by-azm819-jufu
Complexity\n- Time complexity: O(m * n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n
azm819
NORMAL
2023-11-26T11:47:03.219979+00:00
2023-11-26T11:47:03.220010+00:00
16
false
# Complexity\n- Time complexity: $$O(m * n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n func largestSubmatrix(_ matrix: [[Int]]) -> Int {\n var result = 0\n\n var prev...
1
0
['Array', 'Greedy', 'Swift', 'Sorting', 'Matrix']
0
largest-submatrix-with-rearrangements
Java Solution for Largest Submatrix With Rearrangements Problem
java-solution-for-largest-submatrix-with-co1q
Intuition\n Describe your first thoughts on how to solve this problem. \nThe approach aims to find the largest submatrix containing only 1s after rearranging th
Aman_Raj_Sinha
NORMAL
2023-11-26T11:28:24.118896+00:00
2023-11-26T11:28:24.118923+00:00
106
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe approach aims to find the largest submatrix containing only 1s after rearranging the columns optimally. It works by first computing the height of each column by counting the consecutive 1s from the top. Then, it sorts each row\u2019s ...
1
0
['Java']
0
largest-submatrix-with-rearrangements
Typescript: sort and without sort solutions (Runtime beats 100%)
typescript-sort-and-without-sort-solutio-jhcg
Complexity\n- Time complexity:\nO(n * m)\n\n- Space complexity:\nO(n)\n\n# Code\n\n// TC (m * n), SC: (n)\nfunction largestSubmatrix(matrix: number[][]): number
alexgavrilov
NORMAL
2023-11-26T09:57:21.787438+00:00
2023-11-26T09:57:21.787464+00:00
50
false
# Complexity\n- Time complexity:\nO(n * m)\n\n- Space complexity:\nO(n)\n\n# Code\n```\n// TC (m * n), SC: (n)\nfunction largestSubmatrix(matrix: number[][]): number {\n const m: number = matrix.length;\n const n: number = matrix[0].length;\n let maxArea: number = 0;\n let prevHeights: [number, number][] = ...
1
0
['Array', 'Greedy', 'Sorting', 'Matrix', 'TypeScript', 'JavaScript']
0