AlgorithmHQ
AlgorithmHQ
  • 188
  • 262 524
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
มุมมอง: 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

ความคิดเห็น

  • @lostincoding
    @lostincoding 2 วันที่ผ่านมา

    what is time complxity and space?

  • @insofcury
    @insofcury 2 วันที่ผ่านมา

    Thank you for the dry run

  • @shivamdan8089
    @shivamdan8089 2 วันที่ผ่านมา

    Is there a more optimized solution for this? As , on leetcode , it's the second best solution to the problem.

  • @SanjayB-vy4gx
    @SanjayB-vy4gx 3 วันที่ผ่านมา

    try to speak fully in english mam

  • @AjeetTiwari018
    @AjeetTiwari018 3 วันที่ผ่านมา

    Coding wo bhi Java se thanks uuu best approach seekhne ko milega 🥹🥹🥹mast daily krana di 🤩

  • @workAP-g5g
    @workAP-g5g 3 วันที่ผ่านมา

    sorry but was breaking for matrix = [[-1,0,-1],[-2,1,3],[3,2,2]]

  • @Siddharthsirsate77
    @Siddharthsirsate77 3 วันที่ผ่านมา

    buy a ticket and restore your streak.

  • @KedarBhawthankar
    @KedarBhawthankar 4 วันที่ผ่านมา

    congratulations for 5k subscribes

    • @algorithmsbyaditi
      @algorithmsbyaditi 3 วันที่ผ่านมา

      Thank you so much for your support!

  • @codeitaviral3
    @codeitaviral3 4 วันที่ผ่านมา

    // // 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; } } };

  • @parth7d2
    @parth7d2 4 วันที่ผ่านมา

    Haina, please, next time try to elucidate more "Why", thank you:)

    • @algorithmsbyaditi
      @algorithmsbyaditi 3 วันที่ผ่านมา

      Thanks for the feedback, I'll keep it in mind!

  • @PriyanshuSarkar-y9k
    @PriyanshuSarkar-y9k 4 วันที่ผ่านมา

    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.

    • @codeitaviral3
      @codeitaviral3 4 วันที่ผ่านมา

      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

    • @PriyanshuSarkar-y9k
      @PriyanshuSarkar-y9k 3 วันที่ผ่านมา

      @@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.

    • @codeitaviral3
      @codeitaviral3 3 วันที่ผ่านมา

      @@PriyanshuSarkar-y9k bro, it just comes with time and number of questions you solve....best wishes

    • @PriyanshuSarkar-y9k
      @PriyanshuSarkar-y9k 3 วันที่ผ่านมา

      @@codeitaviral3 ok i will keep on solving, thank you for your content its helpful keep doing great work.

  • @harishbehera7812
    @harishbehera7812 4 วันที่ผ่านมา

    thank you for the video, well explain . radhe radhe

  • @harishbehera7812
    @harishbehera7812 4 วันที่ผ่านมา

    thank you madam ji for the solution. Radhe Radhe.

  • @lakshyakalra419
    @lakshyakalra419 4 วันที่ผ่านมา

    Just In Time.!!

  • @vaibhavkhandelwal5934
    @vaibhavkhandelwal5934 5 วันที่ผ่านมา

    Understood the concept

  • @ab_naved1362
    @ab_naved1362 5 วันที่ผ่านมา

    How to sol any questions/ also logic ? Lot's of people say sol question on leetcode 200+ then logic automatically come it's true?

    • @algorithmsbyaditi
      @algorithmsbyaditi 4 วันที่ผ่านมา

      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.

  • @parth7d2
    @parth7d2 5 วันที่ผ่านมา

    Okay! Haina 😄 Thank you for taking the time for us.

  • @parth7d2
    @parth7d2 5 วันที่ผ่านมา

    Thanks, Hena? It's quite knotty to understand but well try!

  • @harishbehera7812
    @harishbehera7812 5 วันที่ผ่านมา

    thank you for the solution. Radhe Radhe. create a youtube community to post updates..

  • @NikhileshMauje
    @NikhileshMauje 6 วันที่ผ่านมา

    I think you should Improve your Audio quality, as audio is too low

  • @cris_12535
    @cris_12535 6 วันที่ผ่านมา

    the audio base is very low...

  • @yuvraj4119
    @yuvraj4119 6 วันที่ผ่านมา

    Why don't you start your java course ? You explain wonderful

    • @algorithmsbyaditi
      @algorithmsbyaditi 6 วันที่ผ่านมา

      I will definitely think about it. Thanks!

  • @harishbehera7812
    @harishbehera7812 6 วันที่ผ่านมา

    thank you for the video, well explain. Radhe Radhe

  • @codeitaviral3
    @codeitaviral3 7 วันที่ผ่านมา

    Great work !

  • @gurveersingh5967
    @gurveersingh5967 7 วันที่ผ่านมา

    Great to see you back, I hope everything is good

  • @namangupta1373
    @namangupta1373 7 วันที่ผ่านมา

    Thank you didi for this amazing explanation 😊

  • @harishbehera7812
    @harishbehera7812 7 วันที่ผ่านมา

    thank you for the solution. please try to upload every day problem. Radhe Radhe

    • @algorithmsbyaditi
      @algorithmsbyaditi 7 วันที่ผ่านมา

      Glad you found it useful! I'll try to upload daily.

  • @ANKITVERMA-yu4ro
    @ANKITVERMA-yu4ro 7 วันที่ผ่านมา

    Thank you di. Will solve after 5 days. End semester exams going on.

  • @Lalala_1701
    @Lalala_1701 7 วันที่ผ่านมา

    i am back couldnt do this one so had to see ur video. going strong 62 days

  • @feelfreemusic6875
    @feelfreemusic6875 8 วันที่ผ่านมา

    Please post solutions regularly.

  • @KedarBhawthankar
    @KedarBhawthankar 8 วันที่ผ่านมา

    181 days of streak gone

    • @algorithmsbyaditi
      @algorithmsbyaditi 7 วันที่ผ่านมา

      Sadly

    • @Siddharthsirsate77
      @Siddharthsirsate77 7 วันที่ผ่านมา

      @@KedarBhawthankar buy a ticket from the store with the leetcoins that you get everyday

  • @Siddharthsirsate77
    @Siddharthsirsate77 8 วันที่ผ่านมา

    be consistent

  • @reenachandarana4459
    @reenachandarana4459 9 วันที่ผ่านมา

    Nice and detailed Explanation

  • @codeitaviral3
    @codeitaviral3 10 วันที่ผ่านมา

    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; } };

  • @shivampathak1072
    @shivampathak1072 11 วันที่ผ่านมา

    good explanation

  • @SwapnilPhad-i2l
    @SwapnilPhad-i2l 13 วันที่ผ่านมา

    what a simple way explanation didi,, thanx

  • @MayurZinc
    @MayurZinc 14 วันที่ผ่านมา

    good explaination😇 Radhe Radhe😀

  • @feelfreemusic6875
    @feelfreemusic6875 15 วันที่ผ่านมา

    12 Nov ka POTD ??

  • @Rishav-z6l
    @Rishav-z6l 16 วันที่ผ่านมา

    very nice expanation

  • @YashChandanshiv-xf5kg
    @YashChandanshiv-xf5kg 16 วันที่ผ่านมา

    great approach

  • @arshiyaarshiya9620
    @arshiyaarshiya9620 16 วันที่ผ่านมา

    What's the time and space complexity and their percentage among others

  • @harshitmishra1673
    @harshitmishra1673 17 วันที่ผ่านมา

    how you developed your logic skill.. i am trying hard but still lacking can you help me please

    • @algorithmsbyaditi
      @algorithmsbyaditi 7 วันที่ผ่านมา

      Keep practicing and you will develop your logic skills over time!

  • @ssss22144
    @ssss22144 17 วันที่ผ่านมา

    Please create videos in English, I am from Telugu I also understand English but not Hindi

    • @ssss22144
      @ssss22144 17 วันที่ผ่านมา

      Nice explanation, try to make it in English

  • @animeshkumar564
    @animeshkumar564 17 วันที่ผ่านมา

    at 9:20 why r u taking the ans =n+1 or 4 ?

    • @algorithmsbyaditi
      @algorithmsbyaditi 17 วันที่ผ่านมา

      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.

  • @khushantwankhede8311
    @khushantwankhede8311 17 วันที่ผ่านมา

    Thankyou so much maam , Radhe radhe !

  • @harishbehera7812
    @harishbehera7812 17 วันที่ผ่านมา

    Radhe Radhe. thanx you for the solution. really very helpful.

  • @NishantPandat-l3q
    @NishantPandat-l3q 17 วันที่ผ่านมา

    aur voice bhi thoda tej kar dijiye mam

  • @NishantPandat-l3q
    @NishantPandat-l3q 17 วันที่ผ่านมา

    good explain mam....sath me thod concept bhi explain kr diya karo

  • @ANKITVERMA-yu4ro
    @ANKITVERMA-yu4ro 17 วันที่ผ่านมา

    Thank you di. solved today's problem of the day 😃

  • @CrazyRD-h4d
    @CrazyRD-h4d 18 วันที่ผ่านมา

    ❤❤