for 2nd question, I was not able to come up with this logic during the contest, now that I see this, it seems easy, but, would request you to suggest any other ideas too, though I understand that this is the easiest possible logic
I was able to come up with the exact same approach for the 4th question but missed it just by some mins due to wrong coordinates , However Will memoizing the answer for a particular set of rectangles optimize the soln any further or there would be no overlapping rectangles?
Please fill the feedback form: forms.gle/UetQqvq4TiZVZtbx7
[2, -3, -7] taking subarrays [2, -3, -7] or [2, -3] and [-7] gives -2 as total cost but taking subarrays [2] and [-3, -7] gives you 6 as total cost...
Very Well Explaination Viraj Sir !!
Here is my approach for the 2nd question
class Solution {
public:
int findMax(const vector& indexArray) {
if (indexArray.empty()) return -1;
return *max_element(indexArray.begin(), indexArray.end());
}
int findMin(const vector& indexArray) {
if (indexArray.empty()) return -1;
return *min_element(indexArray.begin(), indexArray.end());
}
int minimumArea(vector& grid) {
int rows = grid.size();
int cols = grid[0].size();
vector oneRowIndex;
vector oneColIndex;
for(int i = 0; i < rows; i++) {
for(int j = 0; j < cols; j++) {
if(grid[i][j] == 1) {
oneRowIndex.push_back(i);
oneColIndex.push_back(j);
}
}
}
if(oneColIndex.empty()) return 0;
int minRow = findMin(oneRowIndex);
int maxRow = findMax(oneRowIndex);
int minCol = findMin(oneColIndex);
int maxCol = findMax(oneColIndex);
int height = maxRow - minRow + 1;
int width = maxCol - minCol + 1;
return height * width;
}
};
Good explanation with how he thinks about the problem in the contest
brother!!, beautiful explanation for 4th one
amazing explanation of the d question!
for 2nd question, I was not able to come up with this logic during the contest, now that I see this, it seems easy, but, would request you to suggest any other ideas too, though I understand that this is the easiest possible logic
great explaination bhaiya 😊
Great explanation of 4th ,understood competely
Virajj !! Great explanation!!❤
best mentor❤
Understood
The solution for third is giving TLE in java
For Q3 how to tackle during the contest as their problem statements are such bullshit... though Excellent explanation brother🔥
I was able to come up with the exact same approach for the 4th question but missed it just by some mins due to wrong coordinates , However Will memoizing the answer for a particular set of rectangles optimize the soln any further or there would be no overlapping rectangles?
I did not think about this since this seemed within the TC boundaries.
im going to see ur code.....just to copy those boxes you draw for future reference 😏
Hahaha lol
Viraj 🫡🫡🫡
very nice solution of 3rd and 4th bro
No audio..😢
The audio issue at some specific timestamp or in the entire video?
bro use darkmode.
Ok Bro. I'll take care.
Leetcode contest are so shit now
true, they should be more hard
whenever i see dp problem doing greedily!!🥲