Maximum Absolute Sum of Any Subarray | Kadane's Algorithm | Leetcode 1749 | codestorywithMIK

preview_player
Показать описание

Hi Everyone, this is the 144th video of our Playlist "Arrays 1D/2D : Popular Interview Problems".
Now we will be solving a good Array based problem - Maximum Absolute Sum of Any Subarray | Kadane's Algorithm | Leetcode 1749 | codestorywithMIK

We will also study what Kadane's Algorithm is and how this problem is related to it.

Kadane's Algorithm is a very famous technique used to find the maximum sum subarray in a given array of numbers. It works by iterating through the array while maintaining a running sum (current_sum) and updating the maximum sum (max_sum) found so far. You can tweak it to find minimum sum subarray as well.

Problem Name : Maximum Absolute Sum of Any Subarray | Kadane's Algorithm | Leetcode 1749 | codestorywithMIK
Company Tags : will update later

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

Video Summary :
Approach 1 (Two-Pass Kadane’s Algorithm):
This approach runs Kadane’s Algorithm twice—first to find the maximum subarray sum and then to find the minimum subarray sum. The intuition is that the absolute value of the minimum subarray sum could be larger than the maximum subarray sum, so both need to be considered. Finally, the result is the maximum of these two values.

Approach 2 (One-Pass Kadane’s Algorithm):
This approach optimizes the process by combining both calculations into a single pass through the array. It simultaneously tracks the maximum and minimum subarray sums, updating them as it iterates. By doing this in one loop, we achieve the same result with improved efficiency while maintaining clarity in logic.

✨ Timelines✨
00:00 - Introduction
0:25 - Motivation
1:07 - Problem Explanation
3:09 - Thought Process
4:23 - Why maxSubarraySum and minSubarraySum only ?
8:09 - One more example
13:25 - Why Kadane's Algorithm
14:56 - What is Kadane's Algorithm + Dry Run
24:48 - coding : 2 Pass Solution
28:01 - Coding : 1 Pass Solution

#MIK #mik #Mik
#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 #coding #programming #100daysofcode #developers #techjobs #datastructures #algorithms #webdevelopment #softwareengineering #computerscience #pythoncoding #codinglife #coderlife #javascript #datascience #leetcode #leetcodesolutions #leetcodedailychallenge #codinginterview #interviewprep #technicalinterview #interviewtips #interviewquestions #codingchallenges #interviewready #dsa #hindi #india #hindicoding #hindiprogramming #hindiexplanation #hindidevelopers #hinditech #hindilearning #helpajobseeker #jobseekers #jobsearchtips #careergoals #careerdevelopment #jobhunt #jobinterview #github #designthinking #learningtogether #growthmindset #digitalcontent #techcontent #socialmediagrowth #contentcreation #instagramreels #videomarketing #codestorywithmik #codestorywithmick #codestorywithmikc #codestorywitmik #codestorywthmik #codstorywithmik #codestorywihmik #codestorywithmiik #codeistorywithmik #codestorywithmk #codestorywitmick #codestorymik #codestorwithmik
Рекомендации по теме
Комментарии
Автор

Good morning bhaiya🙏
I am thrilled to tell you that I've cracked internship at Microsoft :) Thanks alot for putting in dsa content and making us fall in love with dsa 🥺 And todays motivation hits different and feels like a personal advice from youu ❤
Thank youu once again for all your hardwork 🥺🙏

Hpktube
Автор

I was waiting for kadane's algo video since long time. If someone is looking for brute force code for the today's question so here it is with O(n^2) complexity
int maxAbsoluteSum(vector<int>& nums) {
int n=nums.size();
int ans=0;

for(int i=0;i<n;i++){
int sum=0;
for(int j=i;j<n;j++){
sum+=nums[j];
ans=max(ans, abs(sum));
}
}

return ans;
}

mananatal
Автор

Believe me, i have never seen anything so crystal clearly explained !!!
Aag laga di bhai ne 🔥

Thanks a lot 🙏🏻

souvik
Автор

The best explanation of Kadane's algorithm 🔥🔥🔥🔥.

SRoy
Автор

Thank you MIK, hope you get better soon...

aizadiqbal
Автор

The clarity from yesterday’s question helped me solve today’s DCC effortlessly. I truly appreciate and thankyou your dedication and efforts

lokeshpatidar
Автор

yaar maza hi agaya is problem me. the moment you said kadane's, the problem is over. thanks legend

aws_handles
Автор

Great observation and perspective. Wish you speedy recovery MIK, get well soon.

ashwinrao
Автор

fan of your teaching and approach brooo loved it 🥰

sameersoni
Автор

Thankyou!! for the well explanation of Kadane's Algorithm.✅👍🏼

shubhamm
Автор

in the between of the lecture, i solved it on my own after your fantastic explanation and solved the max subarray sum problem

VineetDixit
Автор

Done by myself. Aur with full visualization. I took 5 hrs to understand Yesterday's problem but it was all worth it, today i just took 15min to solve this.

DeteroyteGaming
Автор

toaday's motivation hits diiferent, can really relate from this.

bhuppidhamii
Автор

Solved it on my own in first go thanks mik sir ....

prathameshjadhav
Автор

From now on, my brain wont forget Kadane's Algo😁😃. MIK is like demi god for us 🥰❣

spidey-uc
Автор

6:21 me hi figure out hogaya. thanks a lot MIK
and the question was really good.

EB-otuu
Автор

Thank you for creating such insightful and helpful videos, bhaiya! Your content is truly valuable, and I really appreciate the effort you put into making these!!

sarthakrajput
Автор

Sir please ek video bna do jisme isliye identity kr sake ki problem kis topic se hoga solve subarray wale problem me confuse ho jate hai prefix sum, lagega sliding window lagega pls help

Anime-ubvs
Автор

bhai aapki approach bhot achi h but try to make it small, for your growth you must make it short yr pls

pragatmittal
Автор

Kadane's made this problem super easy. thank you sir.

gui-codes