Number of Submatrices That Sum to Target | Subarray Sum Equals K | Leetcode 1074 | Leetcode 560

preview_player
Показать описание
This is the 80th Video of our Playlist "Array 1D/2D Programming : Popular Interview Problems".
In this video we will try to solve two very good Array problems -
Subarray Sum Equals K (Leetcode 560)
K Inverse Pairs ArrayNumber of Submatrices That Sum to Target (Leetcode 1074)

I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.

Problem Name : K Inverse Pairs ArrayNumber of Submatrices That Sum to Target | Subarray Sum Equals K | Leetcode 1074 | Leetcode 560
Company Tags : Meta, Amazon, Netflix, Apple, Google, Amazon
My solutions on Github(C++ & JAVA) :

Approach Summary (Leetcode-560) : The approach uses a map (mp) to keep track of cumulative sums encountered during the iteration through the input array. It initializes sum to zero and increments it as it iterates through the array. The map is used to store the count of each cumulative sum. The algorithm checks if the difference between the current cumulative sum (sum) and the target value (k) exists in the map. If it does, it adds the corresponding count to the result. Finally, the count of the current cumulative sum is updated in the map. The function returns the total count of subarrays with the sum equal to k.

Approach Summary (Leetcode-1074) : The approach involves iterating through all possible starting and ending points (rows and columns) of submatrices within the given matrix. For each combination of starting and ending points, it calculates the sum of elements within the submatrix and increments the result count if the sum matches the target. The function returns the total count of submatrices with the sum equal to the target. This solution has a time complexity of O(m^2 * n^2), where 'm' is the number of rows and 'n' is the number of columns in the matrix. It can be optimized further using precomputation or dynamic programming techniques.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

✨ Timelines✨
00:00 - Introduction
00:31 - Leetcode-560 Problem Explained
1:46 - Leetcode-560 Brute Force
4:25 - Leetcode-560 Optimal Intuition with Dry Run
16:53 - Leetcode-560 Live coding
19:12 - Leetcode-1074 Problem Explained
21:14 - Leetcode-1074 Brute Force
24:46 - Leetcode-1074 Optimal Intuition with Dry Run
51:25 - Leetcode-1074 Live coding

#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear
Рекомендации по теме
Комментарии
Автор

I promise, I will make you famous in my college ❤ you are underrated dsa teacher.

adarsh_
Автор

Apologies for the delay guys. I am packing for my next trip to Mussoorie.
I hope you guys will like the explanation.
Thank you all . Love you all ❤
Because of the trip, Contest problems will be delayed this week 🙏

codestorywithMIK
Автор

It feels illegal to get this Dope content free of cost . Single handedly this guy is beating paid courses like scaler, gfg, bosscoder etc.

Hats off legend.
Enjoy the trip.

DevOpskagyaan
Автор

There are so many youtubers who are very famous for teaching DSA but your channel is super underrated. I wish I had started my preparation by learning from your videos. Great work!!! Love your consistency and hard work

malvikachoudhary
Автор

Before watching MIK's video this question was very verty HARD.
But after watching the dry-run it became too EASY.
Thanks a lot MIK .

molyoxide
Автор

ek bar m hi chal gya code wo bhi without any error ... kya gazab ka smjahaya boss ek Number..

manishjoshi
Автор

22:00, i dint knew how to find all submatrix till now, surprising i did not knew it

cash
Автор

standing ovation for this legend ...what a legend he is

atifakhtar
Автор

I promise i will be a daily visitor to your channel and crack a job ! You are the best sir ❤ God level explanation

sudipsarkar
Автор

sir thankyou so much for creating this video, you explain so well each and every point is crystal clear. 🥰

ananyieie
Автор

No matter how tough the questions in the daily challenge may be, I find confidence knowing that if I stumble, you're there to turn the challenge into a piece of cake. Grateful for your support!

Thank You for this beautiful story.❣
If you get time then please tell us a story of today's weekly contest problem - 2, 3, 4... ❣
I was not able to solve question-2 :(

Abhi_
Автор

never heard of `1 Q's ke saath 1 free!`
thank, you're great work

bhuppidhamii
Автор

such a great explanation ... Loved it, i have personally seen all the available explanation present for this question, but no one has explained it so perfectly

HRISHABHJAISWAL
Автор

The video was really explanatory. I understood the question really well but i think for solving questions like these in interviews, we have to prior do questions like these. amazing video <3

divyanshupant
Автор

u r the legend u r the best god bless u big brother love you, whenever i watch ur content u made my day

ankit_yadav
Автор

WOW!!! best explaination possible <3 loved it

Shauryacious
Автор

Bhaiya for the first problem, instead of inserting {0, 1} in map for the first time, cant we check this with this code like : if(sum==0 ) count++; if(arr[i]==0) count++; ? Map me pehle insert karna intuition thoda hard laga, but it was worth it !!. Thanks for the content bhaiya ❤

subhajitdey
Автор

whenever i was not able to solve the leetcode POTD then i always wait for your video. your are just op OP EXPLANATION ❤💝

shambhojaybhaye
Автор

I pray everyday to God for u...
U r such a gem Bhaiya❤❤

oqant
Автор

I am grateful that I found your Channel💫.

closer
join shbcf.ru