Тёмный

Max Contiguous Subarray Sum - Cubic Time To Kadane's Algorithm ("Maximum Subarray" on LeetCode) 

Back To Back SWE
Подписаться 242 тыс.
Просмотров 233 тыс.
50% 1

Code & Problem Statement @ backtobackswe....
Free 5-Day Mini-Course: backtobackswe.com
Try Our Full Platform: backtobackswe....
📹 Intuitive Video Explanations
🏃 Run Code As You Learn
💾 Save Progress
❓New Unseen Questions
🔎 Get All Solutions
Question: Given an integer array, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Approaches Covered:
Approach 1 O(n^3) Time Solution
Approach 2 O(n^2) Time Solution
Approach 3 O(n) Solution (Kadane's Algorithm)
- - maxSum[i] = max( A[i], A[i] + maxSum[i - 1] )
++++++++++++++++++++++++++++++++++++++++++++++++++
HackerRank: / @hackerrankofficial
Tuschar Roy: / tusharroy2525
GeeksForGeeks: / @geeksforgeeksvideos
Jarvis Johnson: / vsympathyv
Success In Tech: / @successintech

Опубликовано:

 

4 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 793   
@BackToBackSWE
@BackToBackSWE 5 лет назад
Table of Contents: The Problem Introduction 0:00 - 0:31 What I Think Immediately 0:31 - 0:55 What Is A Contiguous Subarray 1:00 - 1:52 Jumping To The Brute Force Quickly 1:52 - 2:34 Search Contig. All Subarrays: Birth of Brute Force 2:34 - 3:01 Cubic Time Approach 3:01 - 4:30 Cubic and Quadratic Solutions Search All Windows 4:30 - 4:35 Why The Cubic Solution Is Slower 4:35 - 5:34 Bottlenecks, Unnecessary Work, Duplicate Work 5:34 - 6:04 How To Compute Subarray Sums Better 6:04 - 7:32 Can We Improve To Linear Time? 7:32 - 7:54 Establishing The Fundamental Subproblems 7:54 - 10:32 Establishing Our Fundamental Choice 10:32 - 13:23 Walking Through The Dynamic Programming Table 13:23 - 17:54 We Are Done Filling The Table Out 17:54 - 18:14 The Best Answer To Our Question 18:14 - 18:30 This Does Not Need To Sink In At Once 18:30 - 18:46 Time & Space Complexity 18:46 - 18:58 Wrap Up 18:58 - 19:18 The code is in the description fully commented for teaching purposes.
@reyou7
@reyou7 5 лет назад
OMG this break through! You gotta be really serious about creating array's and numeric ranges 😁🤣
@BackToBackSWE
@BackToBackSWE 5 лет назад
yo
@gondcor
@gondcor 4 года назад
The code is not found here github.com/bephrem1/backtobackswe/blob/master/Dynamic%20Programming%2C%20Recursion%2C%20%26%20Backtracking/MaxContiguousSubarraySum/MaxContiguousSubarraySum.java
@harshgupta1999
@harshgupta1999 4 года назад
@@BackToBackSWE where do i find the code?
@marvelfan5444
@marvelfan5444 4 года назад
Hey I have a problem with the video. Consider the array you used, but only the first 3 numbers in the array (-2,1,-3). While using your approach for the O(n) solution you mentioned the best value at index 2 would be -2. But the answer should be ONE right? Because the best value SO FAR would be the value one. Which is the second number in the array. But you mentioned the best value HAS to involve only either (prev best sum + current element) or only current element...
@bkuls
@bkuls 5 лет назад
This video should win Nobel Prize in the "Explain me like I'm five" category. Seriously wow.
@BackToBackSWE
@BackToBackSWE 5 лет назад
haha
@Oda3908
@Oda3908 3 года назад
@@BackToBackSWE You are amazing, I cant believe I solved the problem easily after watching your explain. Great Job!!
@IsaacAlcocer
@IsaacAlcocer 3 года назад
you need to understand not all the users searching for this speak English... or even know anything about CS or IT..., I would love to see him explaining that 1, 2, 3 is continuous or -1, 2, 5
@anarce
@anarce 5 лет назад
Really surprise your channel is not getting more attention. Sometimes I feel like I have a learning disability but your style of teaching has helped me immensely. Please keep it up!
@BackToBackSWE
@BackToBackSWE 5 лет назад
Hahaha, thanks
@aliasgar1648
@aliasgar1648 5 лет назад
The curiosity and excitement in the way you teach took my interest to another level
@BackToBackSWE
@BackToBackSWE 5 лет назад
Fascinating. Check out tomorrow's video. Much excitement there haha.
@maythecodesbewithyou29
@maythecodesbewithyou29 4 года назад
I am trying to learn from him
@teamadual1237
@teamadual1237 5 лет назад
The best explanation of kadanes algo on the whole internet. thanks alot.
@BackToBackSWE
@BackToBackSWE 5 лет назад
ye
@doublesplitgod6952
@doublesplitgod6952 3 года назад
No one, literally no one can explain THIS BETTER THAN this guy :) The TERM TUTOR is defined for guys like you. Thank You SO much :)
@ferozahmadqureshi8071
@ferozahmadqureshi8071 2 года назад
all other people I have watched explained the code directly, but you made me write it after this video. Kudos man!
@BackToBackSWE
@BackToBackSWE 2 года назад
Thanks for the hardwork
@lpatrasco
@lpatrasco 5 лет назад
Never thought of n^3 solution to this problem. The key to understand DP from n^2 is to understand how we got to n^2 from n^3. WOW!
@BackToBackSWE
@BackToBackSWE 5 лет назад
yeah
@maythecodesbewithyou29
@maythecodesbewithyou29 4 года назад
you are right
@james8522
@james8522 3 года назад
I read 5 different articles and watched 3 different videos to try and wrap my head around Kadane's algorithm. This video is the one that finally made it click. Great job, and thank you for sharing!
@weaponkid1121
@weaponkid1121 3 года назад
Such a good explanation, and I appreciate how you walked through the cubic and quadratic solutions as well, it made it easier to understand the linear solution. Thanks!
@freddie5401
@freddie5401 4 года назад
Just want to let you know I truly appreciate the simplification of these types of problems opposed to portraying these algorithms/problems/solutions with a steep learning curve in a demeaning manner. Really wish I saw these earlier, but all I can control is watching these now! Keep up the excellent work and hope you have a great day.
@BackToBackSWE
@BackToBackSWE 4 года назад
sure and thanks
@sechpham
@sechpham 5 лет назад
I have read and watched so many explanations for this problem and I have to say this video is the best. Others seem like they're just repeating someone else without fully understanding the WHY. I could finally understand why the O(n) solution is written that way. Thank you so much!
@BackToBackSWE
@BackToBackSWE 5 лет назад
nice
@niharikapatil902
@niharikapatil902 5 лет назад
You know your channel is super underrated I don't know why but NO one talks with so much depth into how to think! LOVE this video!
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks, we cookin' up fire out here
@cricketjanoon
@cricketjanoon 11 месяцев назад
I have always known about Kadane's Algorithm and implemented it so many times but never understood the intuition behind it and that it was actually DP. Hats off to you for making me understand this.
@b3aStYyY
@b3aStYyY 4 года назад
Got an interview tomorrow so I was looking for an explanation to Kadane's. Sleepy af right now and yet I still managed to understand the algorithm thanks to you. God damn man, you really do know how to explain complex subjects so that everyone can understand. Best of luck with your endeavours and keep making awesome videos!
@BackToBackSWE
@BackToBackSWE 4 года назад
Ye. Go prosper
@nderitupatrick9949
@nderitupatrick9949 4 года назад
Teachers are our greatest public servants. Teaching is a calling too. You are the best teacher I have seen on youtube
@BackToBackSWE
@BackToBackSWE 4 года назад
lol thx
@snowing906
@snowing906 5 лет назад
I really like the icons for different data structures/algorithms that pop up in the videos. I hope they flash up like that in my interviews too.
@BackToBackSWE
@BackToBackSWE 5 лет назад
hahahahahaha, yeah, I made them all by hand. It took like 4 hours to do the whole set.
@Natasha-ux5pm
@Natasha-ux5pm 4 года назад
@@BackToBackSWE Dude MIT/STANFORD should hire you for sure. haha
@babush7255
@babush7255 5 лет назад
Countless lectures, dozens of RU-vid guides, but thanks to you I've finally got it! Thanks
@BackToBackSWE
@BackToBackSWE 5 лет назад
hahahahahah WOOO! Nice. You are born again 👶
@prerna7900
@prerna7900 2 года назад
If you are at this video, you will not have to look for other video. You are the master of explaining with ease and breakdown. Thank you!
@abebe7017
@abebe7017 5 лет назад
God bless this Dude! I was freaking out for job interviews, and thaks to this channel, I am remembering the materials I learned in fresh year!
@BackToBackSWE
@BackToBackSWE 5 лет назад
nice! good luck friend
@shaswatkumar362
@shaswatkumar362 4 года назад
You are one of the best teachers I have encountered on RU-vid. You broke the solution effortlessly as if it was an easy one. Thanks for all the effort and keep making videos. Cheers!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@mayurkoli4145
@mayurkoli4145 4 года назад
really your efforts in making videos reflect, How someone can dislike your video's i mean, they are Exceptional. just want a request you, "DON'T EVER EVER ...... EVER STOP".
@BackToBackSWE
@BackToBackSWE 4 года назад
ok
@abhishekmukherjee2091
@abhishekmukherjee2091 4 года назад
You are my teacher and guide to dynamic programming problems.Now i know what really dynamic programming is.Thanks a lot.
@BackToBackSWE
@BackToBackSWE 4 года назад
great
@marcossneijder
@marcossneijder 2 года назад
Bought cracking the code interview and never really understood this problem. This was the best explanation I've seen so far, I can even code it by myself
@DanT-iu6oc
@DanT-iu6oc 4 года назад
2 minutes in and I already know this is the best damn explanation I'm ever going to get on this subject. You are wickedly talented at this. Knowing nothing else about you, I would say this is your calling. You're simply too good at it
@BackToBackSWE
@BackToBackSWE 4 года назад
haha well, I try
@sandeshverma517
@sandeshverma517 4 года назад
More then Kaden's problem you just explained me dynamic programming in the best way i could ever learn . I guess i can feel dynamic programming now
@BackToBackSWE
@BackToBackSWE 4 года назад
great
@alfredeben-foby1274
@alfredeben-foby1274 3 года назад
This video right here is GOLD!! it literally forced the concepts of dynamic programming into my skull. I appreciate this.
@aniket1910190
@aniket1910190 3 года назад
I saw this and I right away bought your subscription at backtobackswe.
@Hav0c1000
@Hav0c1000 4 года назад
You seem to have a youtube video for every question that crushes my soul...
@Hav0c1000
@Hav0c1000 4 года назад
Its even more crushing that after I listen to your video... I implement it, and its 6 lines of code... class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ prev = -2**63 maxSum = nums[0] for i in range(len(nums)): prev = max(nums[i],nums[i]+prev) maxSum = max(maxSum,prev) return maxSum
@BackToBackSWE
@BackToBackSWE 4 года назад
​@@Hav0c1000 Nice, and consider that procedural complexity of an algorithm does not always correspond to the intellectual rigor required to create it.
@tombrady7390
@tombrady7390 3 года назад
what makes you stand out is that you are pretty talented plus you put in a lot of effort in making interactive videos. INSANE
@BackToBackSWE
@BackToBackSWE 3 года назад
thanks
@rolandovarela9585
@rolandovarela9585 4 года назад
Enough is enough. I'm subbing. I love how you break things down so well.
@BackToBackSWE
@BackToBackSWE 4 года назад
welcome
@shivanshsuhane8788
@shivanshsuhane8788 4 года назад
I must say, this was an amazing watch! It was an AHA moment really, the first time I wrapped my head around the essence of dynamic programming :)
@BackToBackSWE
@BackToBackSWE 4 года назад
great. glad it helped.
@saurabhverma1381
@saurabhverma1381 3 года назад
Somebody give this guy a Noble Prize. Period.
@notamemer93
@notamemer93 4 года назад
Bro, you are awesome. This is the right way one should explain in to the interviewer in interviews. Never understood Kadane's algorithm before in spite of trying hard. But now I will remember forever. Keep up the good work.
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks
@dragonore2009
@dragonore2009 2 года назад
Explanation was good enough for me to write the code. I work in the industry, and I was never whiteboard tested, so I have no experience with whiteboard interviews. Now I didn't pick up on how to solve this until I saw you explaining this, and then came up with the code to make it work. I hope in a future interview, the interviewer will help me out a little bit, to get me on the right track if I were to quit my job.
@kasturikakatkar
@kasturikakatkar 3 года назад
Thank you for patiently explaining each step right up to the end. I am sure I will never ever forget this algorithm again.
@atulmalakar
@atulmalakar 5 лет назад
I am currently enrolled in B.tech programme from India and believe me I had never thought of such tutorials that you make, in one word you are 'GOD'. I have never seen someone make effort to drive in the intuition behind the problem. I have seen a lot of tutorials over the web but again nothing matches this level. I am 100% sure that this channel would grow by 200% in couple of years. I am definitely sharing this to my friends and peers in support of this awesome and yet again awesome channel. Wishing you best of luck in your journey and I will make sure I contribute in several small ways for the growth of this channel. P.S : I have never written this long comment ever!
@BackToBackSWE
@BackToBackSWE 5 лет назад
hahahahahahahaha, nice, go get em' tiger 🐅🐅
@albertgao7256
@albertgao7256 3 года назад
Just the words "Kadane's Algorithm" should already won you a medal, not to mention the expended explanation! Kudo! A O(n^2) can still pass LeetCode test if you memorize the previous result. But nothing beat O(n)!!
@hsiehalex5007
@hsiehalex5007 2 года назад
Your video about Kadane's Algorithm is the best one ever! Thank you!
@abhishekjha2957
@abhishekjha2957 4 года назад
You are so good at explaining man. You deserve the best.
@BackToBackSWE
@BackToBackSWE 4 года назад
thx.
@Sk8erMorris
@Sk8erMorris 4 года назад
brilliant.. props to the man and his human teaching style
@BackToBackSWE
@BackToBackSWE 4 года назад
yes
@bssun2849
@bssun2849 4 года назад
Way better than some professor from college. Keep going. You have all my support.
@BackToBackSWE
@BackToBackSWE 4 года назад
ok
@shivarammuthukumaraswamy7164
@shivarammuthukumaraswamy7164 4 года назад
OMG BEST video on KADANE's algorithm.TYSM
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks and sure
@sameersondur9030
@sameersondur9030 5 лет назад
I have looked for such an explanation for long. Thanks for making our lives easy!!!! Appreciate it.
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@RaghavendraKumar007
@RaghavendraKumar007 4 года назад
Respect from a fellow coder! Your explanation and energy are unparalleled.
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks and thanks.
@janvisingla3746
@janvisingla3746 4 года назад
hey ,i saw your video for the first time and trust me it was amazing.I saw 5-10 videos of this topic and lastly landed here.Thanku for such a great content.You are really the best.
@BackToBackSWE
@BackToBackSWE 4 года назад
Nice - glad we help
@rns10
@rns10 5 лет назад
When you say best choice among these two, I remember this dialogue in Captain america: Winter soldier which is like - The best we can do is to start over. It fits well in this solution. XD
@BackToBackSWE
@BackToBackSWE 5 лет назад
haha nice
@anubala3311
@anubala3311 4 года назад
I am commenting first time on any of the videos and these are the best tutorials , i have ever seen.
@BackToBackSWE
@BackToBackSWE 4 года назад
great and thanks - appreciated
@duduguan
@duduguan 4 года назад
Cool,the clearest explanition both in all the English and Chinese videos. You deserve a lot more subs.
@BackToBackSWE
@BackToBackSWE 4 года назад
ye
@Natasha-ux5pm
@Natasha-ux5pm 4 года назад
You're a gem of a person! 💓 , I know you've got a new course platform. But you should not stop making more videos, monetise the channel if needed but please keep posting. We love you Ben!
@BackToBackSWE
@BackToBackSWE 4 года назад
Thanks, yeah I've just been coding prety hard since end of November 2019. Should be less in 3-4 months once we have all languages out for testing. Not sure what content to do back here since it is conflict of interest to continue posting free technical walkthroughs. Might do interviews or something.
@ketan_sahu
@ketan_sahu 4 года назад
We need teachers like you ♥
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks.
@chspx
@chspx 6 месяцев назад
You're doing an incredibly impressive and inspiring job. Thank you for your dedication, and for sharing it with the community. Keep up the excellent work! 🚀
@kieran2347
@kieran2347 3 года назад
I struggle with codewars and solving such challenges a lot but I must admit, the way you explain is the best I've seen so far. Thank you for this
@pif5023
@pif5023 Год назад
Blast of a video! Crisp, clear thorough! Love the energy, very helpful
@pksanthoshkumar
@pksanthoshkumar 5 лет назад
Absolutely phenomenal explanation for a complex problem!
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@mariagu9967
@mariagu9967 2 года назад
Very good explaination and the whole video leads us to think instead of just telling us answer! Thanks!
@SendiSiradj
@SendiSiradj 3 года назад
You save me. This is the ultimate solution to my programming assignment. Thank you :)
@tristanlaw2234
@tristanlaw2234 4 года назад
Thank you so much bro, you are the first one explained that why get max between (current_sum+i, i) instead of get max between (current_sum+i, current_sum).
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@gavravdhongadi9824
@gavravdhongadi9824 2 года назад
One of my fav channels. I wish you had received more attention,
@dhruvkaushal8708
@dhruvkaushal8708 5 лет назад
Loved your way of teaching! You earned a follower today sir. Hope you continue to make more such videos.
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks. Psssssst...you and I...we are gonna change the world :)
@dhruvkaushal8708
@dhruvkaushal8708 5 лет назад
@@BackToBackSWE 5 months till I'm going to start looking for jobs, hope to make a smashing entry 🔥😜
@shanesreal
@shanesreal 3 года назад
wow this is an amazing explanation of kadane's algorithm
@reneeliu6676
@reneeliu6676 5 лет назад
I need to subscribe to this. Teacher is good looking (checked) Teacher teaches really well (checked) Teacher is passionate on his stuff (checked).
@BackToBackSWE
@BackToBackSWE 5 лет назад
hahaha, best comment on the channel ever
@reneeliu6676
@reneeliu6676 5 лет назад
@@BackToBackSWE haha! Keep up with those 3 checkpoints okay?
@BackToBackSWE
@BackToBackSWE 5 лет назад
@@reneeliu6676 got ya
@snake1625b
@snake1625b 5 лет назад
absolutely lovely. the best explanation of the ones I've seen on the internet.
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@diveruzumaki5556
@diveruzumaki5556 3 года назад
The best explanation of kadane's algorithm !
@chaericherry1
@chaericherry1 2 года назад
I wasn't understanding Kadane's algorithm for the life of me but this video really cleared everything up. Thank you sir!
@skhimsara
@skhimsara 5 лет назад
Hands down the best and most intuitive explanation of Kadane's algo. Awesome!
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@chettriyuvraj
@chettriyuvraj 2 года назад
Was struggling to grasp the solution intuitively until you explicitly pointed out what the sub-problem being solved at each step is! Thanks :))
@john_rambo_27098
@john_rambo_27098 5 лет назад
I think the entire video was beautifully summed up in the time slice 16:45-16:50 ... beautiful.
@BackToBackSWE
@BackToBackSWE 5 лет назад
hahaha, life is elegant ain't it
@kevint6878
@kevint6878 5 лет назад
Nawazish Khan I know right! That line made me stop to try and really let that sink in because of how much it actually made sense.
@BackToBackSWE
@BackToBackSWE 5 лет назад
@@kevint6878 ha nice, meanwhile I don't even remember making this video haha
@zentiasas
@zentiasas 4 года назад
I appreciate the amount of effort you put in for preparing each content. The content is amazing and best explanation videos and strategy for interviews. I'm preparing for interviews and I can feel that. Thanks a lot. May you transform more and more lives with your content. Keep posting. :)
@BackToBackSWE
@BackToBackSWE 4 года назад
Thanks.
@guruvigneshnagaraj8501
@guruvigneshnagaraj8501 4 года назад
This guy is brillant!! Kudos to your effort!! Thank you!
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks
@yushenni9216
@yushenni9216 4 года назад
Appreciate that! I can tell this video has taken a lot of time! The thing I did not understand was the key to this strategy of DP: subproblem should be what is the maximum END of this index instead of what is the maximum has the length of the end at this index. Thanks a lot!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@rusureaboutthat781
@rusureaboutthat781 3 года назад
U can have all the Phd's in the world but if you lack passion about teaching and what you teach, you wont achieve anything. Thank you sir, for doing what my proffesor dreams of.
@shivaymalhotra1399
@shivaymalhotra1399 5 лет назад
Wowwwwwwwwwwwwwwwwwwwwwwww. God Level Teaching bro.Subscribed your channel in no time after seeing this.
@BackToBackSWE
@BackToBackSWE 5 лет назад
hahah thanks, we have a coding interview class, you should check it out
@karthikaruna1994
@karthikaruna1994 5 лет назад
Really appreciate your efforts to make your audience understand!
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@taruntrikha5262
@taruntrikha5262 3 года назад
Love your content so much that I search for a concept on RU-vid with your channel name to get explanations from you if they are available and then go to other content if your's is not available on that topic. Great work.
@rares7mih8
@rares7mih8 3 года назад
Honestly, this is by far the best channel I've found to explain these questions. Liked and subscribed, thanks for the awesome content!
@eddyneedsahobby
@eddyneedsahobby 4 года назад
14 mins in and im starting to understand. Thank you!!!!!!!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@siddhantaggarwal8218
@siddhantaggarwal8218 5 лет назад
The DP solution is amazingly taught!
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@MoinakChakarborty
@MoinakChakarborty 4 года назад
The best explanation I ever found
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks and hey
@jyl4990
@jyl4990 4 года назад
Please keep it up.. Your explanation is really helpful to computing science student like me, who is not that smart on solving problems but yet still hoping to challenge myself to make it through the interview! Keep it up man!
@BackToBackSWE
@BackToBackSWE 4 года назад
ok
@ed2023bc
@ed2023bc 4 месяца назад
Very detailed explanation with a big array! Thank you .
@tekk7989
@tekk7989 4 года назад
I see how we get 6 as the maximum sum, but how do we get the subarray? In other words, once we get 6, how do we know that 6 is the sum of these four numbers [4, -1, 2, 1]? Edit: nvm, the problem does not require us to return the subarray. Thank you, this is the best, easiest to understand explanation on youtube.
@BackToBackSWE
@BackToBackSWE 4 года назад
If we did want to return it, often in dp we can backtrack on the same recurrence. I don't remember the nuances of the code (replying to comments fast), but there is a way.
@ashishdukare1313
@ashishdukare1313 4 года назад
I love the way he tells how to approach the question
@BackToBackSWE
@BackToBackSWE 4 года назад
yes
@prithvib8662
@prithvib8662 4 года назад
Awesome video! You always do an excellent job of breaking down difficult concepts into an easy to understand fashion. . If anyone was wondering, you can also return the range of values that add up to the maximum subsequence sum like this (In Python): def maxSubArraySum(inputArr): currentMaxSum = inputArr[0] seqStartVal = inputArr[0] . for i in range(1, len(inputArr), 1): #for(i=1; i seqStartVal + inputArr[i]): seqStartVal = inputArr[i]; maxSubSeqStart = i else: seqStartVal += inputArr[i] . if (seqStartVal > currentMaxSum): currentMaxSum = seqStartVal maxSubSeqEnd = i . All we are doing is opening up the "max" function to allow for more logic where we can update the values of TWO MORE variables that track the value of the start and stop points of the max subsequence. Then simply print the values between those two points inclusively via another loop and you will output all the values involved in coming up with the maximum sum.
@BackToBackSWE
@BackToBackSWE 4 года назад
I'm not sure
@prithvib8662
@prithvib8662 4 года назад
@@BackToBackSWE I managed to figure it out. If it's alright with you, I'll update my original comment with the answer.
@BackToBackSWE
@BackToBackSWE 4 года назад
​@@prithvib8662 nice
@EspoirMurhabazi
@EspoirMurhabazi 4 года назад
There no way to give a 100 likes .... but you deserve it, man.....!!
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks and thanks
@इंसान-न4ढ
@इंसान-न4ढ 5 лет назад
Amazing Amazing. These kind of resources motivate me to do more of CP.
@BackToBackSWE
@BackToBackSWE 5 лет назад
ye
@ganapatibiswas5858
@ganapatibiswas5858 4 года назад
Good to see you are providing tushar's video too..
@BackToBackSWE
@BackToBackSWE 4 года назад
what did I do haha
@omarDIY
@omarDIY 5 лет назад
This is a great video. I'd like to see a video on the thought process of how you arrive at the definition for your subproblem
@BackToBackSWE
@BackToBackSWE 5 лет назад
Kadane's is a famous algorithm that someone probably wouldn't get in an interview.
@NikhilWhiskyKumar
@NikhilWhiskyKumar 4 года назад
loved ur gist code , got everything ezly.... thank u. LOVE FROM INDIA
@BackToBackSWE
@BackToBackSWE 4 года назад
great
@Userk77777
@Userk77777 4 месяца назад
Thank you, sir! You explained it with great energy and clarity.
@JRK_RIDES
@JRK_RIDES 4 года назад
At least I thought of the Brute Force approach correctly. I was also close to the approach you showed but it was taking too much time so I just decided let's take little help. Thanks, Brother !!!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@avipatel1534
@avipatel1534 3 года назад
Hey I was struggling to wrap my head around this problem but this video perfectly clarrified everything!
@uarangat
@uarangat 4 года назад
Wonderful teaching skills Brother, Love from India. Keep up your good work.
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks and thanks
@arjan1569
@arjan1569 5 лет назад
This video really helps! Thanks for making it :)
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@mintlata
@mintlata 2 года назад
Wanna say thank you for the great explanation.
@BackToBackSWE
@BackToBackSWE 2 года назад
Awesome
@fuckmyego
@fuckmyego 4 года назад
Thank you so much. I just started codewars and this problem popped up. I've never encountered any dynamic programming before. Watched your video twice and managed to bang out Kadane's Algorithm in python. Onto the next question...
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@yicai7
@yicai7 4 года назад
I really like the way you teach, thank you very much!!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@shyamsr87
@shyamsr87 4 года назад
Great explanation! Kudos for adding table of contents. This is a good video for jumping into DP problems.
@BackToBackSWE
@BackToBackSWE 4 года назад
ye
@chitalvision
@chitalvision 2 года назад
I was kind of skeptical at the start because I couldn't understand you well. But after a rewatch, you've cleared up the concept really well. Thanks a ton!
@yosef908
@yosef908 Год назад
This is the best explanation on kadanes algorithm u got a subscriber
@BackToBackSWE
@BackToBackSWE Год назад
means a lot😄 Would love to hear your thoughts about our FREE DSA course at backtobackswe.com/ 💯
Далее
БАГ ЕЩЕ РАБОТАЕТ?
00:26
Просмотров 247 тыс.
Living life on the edge 😳 #wrc
00:17
Просмотров 5 млн
LeetCode was HARD until I Learned these 15 Patterns
13:00
I Solved 100 LeetCode Problems
13:11
Просмотров 62 тыс.
Making an Algorithm Faster
30:08
Просмотров 104 тыс.
БАГ ЕЩЕ РАБОТАЕТ?
00:26
Просмотров 247 тыс.