- 188
- 262 524
AlgorithmHQ
India
เข้าร่วมเมื่อ 6 ม.ค. 2021
For all the problem solvers and for technology enthusiasts, this channel serves as a hub for finding solutions to coding problems and expanding general knowledge about technology. What began as a hobby has evolved into a dream of making a significant impact, with the goal of becoming a valuable resource for technology enthusiasts everywhere. Our mission is to provide helpful, insightful content that empowers and inspires the tech community.
1975. Maximum Matrix Sum | Leetcode Daily (POTD) 24 Nov 2024 | Java | Medium | Hindi
*"1975. Maximum Matrix Sum"* is a medium-level problem and the daily challenge (POTD) for 24 Nov 2024 on LeetCode. The solution presented in the video is coded in Java, but the approach is explained using a dry-run on a blackboard. This method makes the video accessible and beneficial for individuals with different programming backgrounds, as it focuses on the underlying logic rather than language-specific details.
Intuition:
To maximize the sum of the matrix, we analyze the number of negative elements. If the count of negative numbers is even, all negatives can be flipped to positive regardless of their position, resulting in the maximum possible sum. However, if the count is odd, one element must remain negative. In this case, the goal is to minimize the deduction from the total sum by selecting the smaller value between the largest negative and the smallest positive element. This approach ensures the sum of the matrix is as large as it can be.
Link to the problem: leetcode.com/problems/maximum-matrix-sum/description/
Link to the Java Code: github.com/AditiChourasia/Leetcode-Solutions-AlgorithmHQ/blob/main/1975.%20Maximum%20Matrix%20Sum/Original.java
For doubts/queries, please reach out on aditichourasia10@gmail.com
Connect with me on Linkedin: www.linkedin.com/in/aditi-chourasia-a2a572121/
Other problems for practice:
th-cam.com/video/AAgQAWEqkXA/w-d-xo.html
th-cam.com/video/O0nHjftXIcg/w-d-xo.html
th-cam.com/video/YFvnT6YrYTg/w-d-xo.html
th-cam.com/video/Wd33DnQsLWw/w-d-xo.html
th-cam.com/video/6MH7WAmtwvs/w-d-xo.html
th-cam.com/video/QyiNpKt0iOw/w-d-xo.html
th-cam.com/video/bGq2qViaO4U/w-d-xo.html
th-cam.com/video/fo0BkiytfZA/w-d-xo.html
#leetcodejava #leetcode #dailychallenge #potd #hindi
Intuition:
To maximize the sum of the matrix, we analyze the number of negative elements. If the count of negative numbers is even, all negatives can be flipped to positive regardless of their position, resulting in the maximum possible sum. However, if the count is odd, one element must remain negative. In this case, the goal is to minimize the deduction from the total sum by selecting the smaller value between the largest negative and the smallest positive element. This approach ensures the sum of the matrix is as large as it can be.
Link to the problem: leetcode.com/problems/maximum-matrix-sum/description/
Link to the Java Code: github.com/AditiChourasia/Leetcode-Solutions-AlgorithmHQ/blob/main/1975.%20Maximum%20Matrix%20Sum/Original.java
For doubts/queries, please reach out on aditichourasia10@gmail.com
Connect with me on Linkedin: www.linkedin.com/in/aditi-chourasia-a2a572121/
Other problems for practice:
th-cam.com/video/AAgQAWEqkXA/w-d-xo.html
th-cam.com/video/O0nHjftXIcg/w-d-xo.html
th-cam.com/video/YFvnT6YrYTg/w-d-xo.html
th-cam.com/video/Wd33DnQsLWw/w-d-xo.html
th-cam.com/video/6MH7WAmtwvs/w-d-xo.html
th-cam.com/video/QyiNpKt0iOw/w-d-xo.html
th-cam.com/video/bGq2qViaO4U/w-d-xo.html
th-cam.com/video/fo0BkiytfZA/w-d-xo.html
#leetcodejava #leetcode #dailychallenge #potd #hindi
มุมมอง: 666
วีดีโอ
1861. Rotating the Box | Leetcode Daily (POTD) 23 Nov 2024 | Java | Medium | Hindi
มุมมอง 56712 ชั่วโมงที่ผ่านมา
*"1861. Rotating the Box"* is a medium-level problem and the daily challenge (POTD) for 23 Nov 2024 on LeetCode. The solution presented in the video is coded in Java, but the approach is explained using a dry-run on a blackboard. This method makes the video accessible and beneficial for individuals with different programming backgrounds, as it focuses on the underlying logic rather than languag...
1072. Flip Columns For Maximum Number of Equal Rows | Leetcode Daily (POTD) 22 Nov 2024 | Java
มุมมอง 99814 ชั่วโมงที่ผ่านมา
"1072. Flip Columns For Maximum Number of Equal Rows" is a medium-level problem and the daily challenge (POTD) for 22 Nov 2024 on LeetCode. The solution presented in the video is coded in Java, but the approach is explained using a dry-run on a blackboard. This method makes the video accessible and beneficial for individuals with different programming backgrounds, as it focuses on the underlyin...
2257. Count Unguarded Cells in the Grid | Leetcode Daily (POTD) 21 Nov 2024 | Java
มุมมอง 40916 ชั่วโมงที่ผ่านมา
*2257. Count Unguarded Cells in the Grid* is a medium-level problem and the daily challenge (POTD) for 21 Nov 2024 on LeetCode. The solution presented in the video is coded in Java, but the approach is explained using a dry-run on a blackboard. This method makes the video accessible and beneficial for individuals with different programming backgrounds, as it focuses on the underlying logic rath...
2516. Take K of Each Character From Left and Right | Leetcode Daily (POTD) 20 Nov 2024 | Java
มุมมอง 88119 ชั่วโมงที่ผ่านมา
*"2516. Take K of Each Character From Left and Right"* is a medium-level problem and the LeetCode daily challenge (POTD) for 20 November 2024. The solution, written in Java, is explained with a dry-run on a blackboard to emphasize logic over language-specific details, making it accessible to diverse audiences. *Intuition:* To minimize the number of characters taken, focus on maximizing the char...
3097. Shortest Subarray With OR at Least K II | Leetcode Daily (POTD) 10 Nov 2024 | Medium | Java
มุมมอง 1.4K14 วันที่ผ่านมา
*"3097. Shortest Subarray With OR at Least K II"* is a medium-level problem and the LeetCode daily challenge (POTD) for 10 November 2024. The solution, coded in Java, is explained through a dry-run on a blackboard to highlight logic over specific syntax, making it accessible for different programming backgrounds. *Intuition:* Apply a sliding window approach using two pointers. Expand the window...
3133. Minimum Array End | Leetcode Daily (POTD) 9 Nov 2024 | Medium | Java | Hindi
มุมมอง 1.5K14 วันที่ผ่านมา
*"3133. Minimum Array End"* is a medium-level problem and the daily challenge (POTD) for 9 Nov 2024 on LeetCode. The solution presented in the video is coded in Java, but the approach is explained using a dry-run on a blackboard. This method makes the video accessible and beneficial for individuals with different programming backgrounds, as it focuses on the underlying logic rather than languag...
1829. Maximum XOR for Each Query | Leetcode Daily (POTD) 8 Nov 2024 | Medium | Java | Hindi
มุมมอง 76014 วันที่ผ่านมา
*"1829. Maximum XOR for Each Query"* is a medium-level problem and the daily challenge (POTD) for 8 Nov 2024 on LeetCode. The solution presented in the video is coded in Java, but the approach is explained using a dry-run on a blackboard. This method makes the video accessible and beneficial for individuals with different programming backgrounds, as it focuses on the underlying logic rather tha...
2275. Largest Combination With Bitwise AND Greater Than Zero | Leetcode Daily (POTD) 6 Nov 2024
มุมมอง 1.2K21 วันที่ผ่านมา
"2275. Largest Combination With Bitwise AND Greater Than Zero" is a medium-level problem and the LeetCode daily challenge (POTD) for 7 November 2024. The solution is coded in Java and explained with a dry-run on a blackboard, making it accessible for a broad audience by focusing on the logic rather than language specifics. *Intuition:* To solve this, count how many integers have a set bit at ea...
3011. Find if Array Can Be Sorted | Leetcode Daily (POTD) 6 Nov 2024 | Java | Hindi
มุมมอง 1.4K21 วันที่ผ่านมา
*"3011. Find if Array Can Be Sorted"* is a medium-level problem and the LeetCode daily challenge (POTD) for 6 November 2024. The solution is coded in Java and explained with a dry-run on a blackboard, making it accessible for a broad audience by focusing on the logic rather than language specifics. *Intuition:* Divide elements into groups based on the count of set bits in each element. Within e...
2914. Minimum Number of Changes to Make Binary String Beautiful | Leetcode Daily (POTD) 5 Nov 2024
มุมมอง 97721 วันที่ผ่านมา
"2914. Minimum Number of Changes to Make Binary String Beautiful" is a medium-level problem and the LeetCode daily challenge (POTD) for 5 November 2024. The solution, coded in Java, is explained using a dry-run on a blackboard, making it accessible for individuals from various programming backgrounds by focusing on the underlying logic. *Intuition:* To split the string into "beautiful" segments...
3163. String Compression III | Leetcode Daily (POTD) 4 Nov 2024 | Java | Hindi | String
มุมมอง 58421 วันที่ผ่านมา
"3163. String Compression III" is a medium-level problem and the daily challenge (POTD) for 4 November 2024 on LeetCode. The solution is coded in Java, with an explanation using a blackboard dry-run, making it accessible to those from different programming backgrounds by focusing on the core logic. *Intuition:* Track the current character and its frequency. Once a new character is encountered, ...
796. Rotate String | Leetcode Daily (POTD) 3 Nov 2024 | Java | Hindi | String
มุมมอง 53121 วันที่ผ่านมา
"796. Rotate String" is a hard-level problem and the daily challenge (POTD) for 3 November 2024 on LeetCode. The solution is coded in Java, with a blackboard dry-run explanation to enhance understanding, making it accessible across different programming backgrounds by focusing on the main logic. *Intuition:* To check if one string is a rotation of another, concatenate the string with itself. If...
1671. Minimum Number of Removals to Make Mountain Array | Leetcode Daily (POTD) 30 Oct 2024 | Java
มุมมอง 78928 วันที่ผ่านมา
"1671. Minimum Number of Removals to Make Mountain Array" is a hard-level problem and the daily challenge (POTD) for 30 October 2024 on LeetCode. The solution is coded in Java, with a blackboard dry-run explanation to clarify the approach, making it accessible to viewers from various programming backgrounds by focusing on core logic. *Intuition:* To find the longest possible mountain array, det...
2684. Maximum Number of Moves in a Grid | Leetcode Daily (POTD) 29 Oct 2024 | Java
มุมมอง 1.1K28 วันที่ผ่านมา
"2684. Maximum Number of Moves in a Grid" is a medium-level problem and the daily challenge (POTD) for 29 October 2024 on LeetCode. The solution is coded in Java, and a dry-run explanation on a blackboard helps make the approach accessible, focusing on the logic rather than language-specific details. Intuition: Use recursion to explore all possible moves in the grid and apply dynamic programmin...
2501. Longest Square Streak in an Array | Leetcode Daily (POTD) 28 Oct 2024 | Java
มุมมอง 739หลายเดือนก่อน
2501. Longest Square Streak in an Array | Leetcode Daily (POTD) 28 Oct 2024 | Java
2458. Height of Binary Tree After Subtree Removal Queries | Leetcode Daily (POTD) 26 Oct 2024 | Java
มุมมอง 1.2Kหลายเดือนก่อน
2458. Height of Binary Tree After Subtree Removal Queries | Leetcode Daily (POTD) 26 Oct 2024 | Java
1233. Remove Sub-Folders from the Filesystem | Leetcode Daily (POTD) 25 Oct 2024 | Java | Hindi
มุมมอง 630หลายเดือนก่อน
1233. Remove Sub-Folders from the Filesystem | Leetcode Daily (POTD) 25 Oct 2024 | Java | Hindi
951. Flip Equivalent Binary Trees | Leetcode Daily (POTD) 24 Oct 2024 | Java | Hindi
มุมมอง 304หลายเดือนก่อน
951. Flip Equivalent Binary Trees | Leetcode Daily (POTD) 24 Oct 2024 | Java | Hindi
2641. Cousins in Binary Tree II | Leetcode Daily (POTD) 23 Oct 2024 | Java | Hindi
มุมมอง 364หลายเดือนก่อน
2641. Cousins in Binary Tree II | Leetcode Daily (POTD) 23 Oct 2024 | Java | Hindi
2583. Kth Largest Sum in a Binary Tree | Leetcode Daily (POTD) 22 Oct 2024 | Java | Hindi
มุมมอง 379หลายเดือนก่อน
2583. Kth Largest Sum in a Binary Tree | Leetcode Daily (POTD) 22 Oct 2024 | Java | Hindi
2044. Count Number of Maximum Bitwise-OR Subsets | Leetcode Daily (POTD) 18 Oct 2024 | Java | Hindi
มุมมอง 667หลายเดือนก่อน
2044. Count Number of Maximum Bitwise-OR Subsets | Leetcode Daily (POTD) 18 Oct 2024 | Java | Hindi
670. Maximum Swap | Leetcode Daily (POTD) 17 Oct 2024 | Medium | Java | Hindi
มุมมอง 662หลายเดือนก่อน
670. Maximum Swap | Leetcode Daily (POTD) 17 Oct 2024 | Medium | Java | Hindi
1405. Longest Happy String | Leetcode Daily (POTD) 16 Oct 2024 | Greedy | Java | Hindi
มุมมอง 760หลายเดือนก่อน
1405. Longest Happy String | Leetcode Daily (POTD) 16 Oct 2024 | Greedy | Java | Hindi
1942. The Number of the Smallest Unoccupied Chair | Leetcode Daily (POTD) 11 Oct 2024 | Java | Hindi
มุมมอง 998หลายเดือนก่อน
1942. The Number of the Smallest Unoccupied Chair | Leetcode Daily (POTD) 11 Oct 2024 | Java | Hindi
962. Maximum Width Ramp | Leetcode Daily (POTD) 10 Oct 2024 | Medium | Java | Hindi
มุมมอง 1.4Kหลายเดือนก่อน
962. Maximum Width Ramp | Leetcode Daily (POTD) 10 Oct 2024 | Medium | Java | Hindi
921. Minimum Add to Make Parentheses Valid | Leetcode Daily (POTD) 9 Oct 2024 | Java | Hindi
มุมมอง 394หลายเดือนก่อน
921. Minimum Add to Make Parentheses Valid | Leetcode Daily (POTD) 9 Oct 2024 | Java | Hindi
1963. Minimum Number of Swaps to Make the String Balanced | Leetcode Daily (POTD) 8 Oct 2024 | Java
มุมมอง 1.1Kหลายเดือนก่อน
1963. Minimum Number of Swaps to Make the String Balanced | Leetcode Daily (POTD) 8 Oct 2024 | Java
2696. Minimum String Length After Removing Substrings | Leetcode Daily (POTD) 7 Oct 2024 | Java
มุมมอง 298หลายเดือนก่อน
2696. Minimum String Length After Removing Substrings | Leetcode Daily (POTD) 7 Oct 2024 | Java
567. Permutation in String | Leetcode Daily (POTD) 5 Oct 2024 | Medium | Java | Hindi
มุมมอง 1.3Kหลายเดือนก่อน
567. Permutation in String | Leetcode Daily (POTD) 5 Oct 2024 | Medium | Java | Hindi
what is time complxity and space?
Thank you for the dry run
Is there a more optimized solution for this? As , on leetcode , it's the second best solution to the problem.
try to speak fully in english mam
Coding wo bhi Java se thanks uuu best approach seekhne ko milega 🥹🥹🥹mast daily krana di 🤩
Glad it was helpful!
sorry but was breaking for matrix = [[-1,0,-1],[-2,1,3],[3,2,2]]
buy a ticket and restore your streak.
congratulations for 5k subscribes
Thank you so much for your support!
// // The below problem has 4 test cases // // 1) All are +ve, no issues // // 2) Even no. of -ve, no issues // // 3) Odd no. of -ve // // 4) Odd no. of -ve & a zero (Here's the c++ soln) class Solution { public: long long maxMatrixSum(vector<vector<int>>& matrix) { int r = matrix.size(); int c = matrix[0].size(); int neg = 0; // Count of negative numbers long long sum = 0; // Total sum of absolute values int minAbs = INT_MAX; // Minimum absolute value in the matrix bool hasZero = false; // Flag to check for zero for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { int val = matrix[i][j]; if (val < 0) neg++; if (val == 0) hasZero = true; sum += abs(val); minAbs = min(minAbs, abs(val)); } } if ((neg & 1) == 0 || hasZero) { // All positive,even negatives or zero present return sum; } else { // Odd negatives and no zero return sum - 2 * minAbs; } } };
Great work!
Haina, please, next time try to elucidate more "Why", thank you:)
Thanks for the feedback, I'll keep it in mind!
I didn't get the 2 deduction part, one more query how you come this logic does it follow some pattern. if there any related problems please share those too for reference thank you.
There's no pattern around it ig, it was some observation. So coming to the -2 logic, so basically when you were calculating sum you had added all the numbers irrespective of - or +, and when you had to deduct the maxneg or minpos. You should substract it it twice as the number was once in the sum
@@codeitaviral3 Thank you for your time, its clear now, one more question how I can be a good problem solver, the observations are that u do blow my mind any tip.
@@PriyanshuSarkar-y9k bro, it just comes with time and number of questions you solve....best wishes
@@codeitaviral3 ok i will keep on solving, thank you for your content its helpful keep doing great work.
thank you for the video, well explain . radhe radhe
Glad it was helpful!
thank you madam ji for the solution. Radhe Radhe.
Glad it was helpful!
Just In Time.!!
Great!
Understood the concept
Glad it was helpful!
How to sol any questions/ also logic ? Lot's of people say sol question on leetcode 200+ then logic automatically come it's true?
Imo it may or may not come with no. of questions as you need to learn to apply concepts that you've learned and identify which question requires which concept. To build logic you should learn a concept and solve a few questions on that before moving on to the other. Also, try to do 1-2 new questions everyday which will expose you to the thingking process of identifying the concept that should be used.
Okay! Haina 😄 Thank you for taking the time for us.
Glad it was helpful!
Thanks, Hena? It's quite knotty to understand but well try!
thank you for the solution. Radhe Radhe. create a youtube community to post updates..
Thank you! I'm working on it!
I think you should Improve your Audio quality, as audio is too low
Will improve, Thanks!
the audio base is very low...
Will improve, Thanks!
Why don't you start your java course ? You explain wonderful
I will definitely think about it. Thanks!
thank you for the video, well explain. Radhe Radhe
Glad it was helpful!
Great work !
Thank you!
Great to see you back, I hope everything is good
Thank you!
Thank you didi for this amazing explanation 😊
thank you for the solution. please try to upload every day problem. Radhe Radhe
Glad you found it useful! I'll try to upload daily.
Thank you di. Will solve after 5 days. End semester exams going on.
Good luck!
i am back couldnt do this one so had to see ur video. going strong 62 days
Glad it was helpful!
my 66 days
Please post solutions regularly.
I will try to, Thanks!
181 days of streak gone
Sadly
@@KedarBhawthankar buy a ticket from the store with the leetcoins that you get everyday
be consistent
I will try to, Thanks!
Nice and detailed Explanation
Thank you!
here's the c++ code for the above question: class Solution { public: #define ll long long vector<string> ans; void helper(ll open, ll close, ll total, string x) { if(x.size() == total) { ans.push_back(x); return; } if(open < total / 2) { x += '('; helper(open + 1, close, total, x); x.pop_back(); } if(open > close) { x += ')'; helper(open, close + 1, total, x); } } vector<string> generateParenthesis(int n) { string x = ""; ll total = 2 * n; helper(0, 0, total, x); return ans; } };
Great work!
good explanation
Thank you!
what a simple way explanation didi,, thanx
Glad it was helpful!
good explaination😇 Radhe Radhe😀
12 Nov ka POTD ??
very nice expanation
Glad you liked it!
great approach
Thank you
What's the time and space complexity and their percentage among others
how you developed your logic skill.. i am trying hard but still lacking can you help me please
Keep practicing and you will develop your logic skills over time!
Please create videos in English, I am from Telugu I also understand English but not Hindi
Nice explanation, try to make it in English
at 9:20 why r u taking the ans =n+1 or 4 ?
We take it because we cannot take -1, as we're using the min function. Taking n+1 ensures that it is an impossible case, as Subarray length cannot be more than the length of the array. So when we return ans, we ensure that ans is not n+1, otherwise we return -1.
Thankyou so much maam , Radhe radhe !
Glad it was helpful!
Radhe Radhe. thanx you for the solution. really very helpful.
Glad it was helpful!
aur voice bhi thoda tej kar dijiye mam
good explain mam....sath me thod concept bhi explain kr diya karo
Will improve, Thanks!
Thank you di. solved today's problem of the day 😃
Glad to hear it!
❤❤