Maximum Sub-Array Sum (LeetCode 53) | Kadane's Algorithm | Study Algorithms
VloĆŸit
- Äas pĆidĂĄn 27. 07. 2024
- Maximum sub-array is a programming challenge on LeetCode. You are provided with an array of integers. These elements could be all positive, all negative or a combination of both. A sub-array is a smaller array formed using the elements of the original array. The condition for this problem is that the elements of the sub-array should be contiguous. Out of all the contiguous sub-arrays possible we need to find the maximum sum that can be formed. Watch the video to understand the problem in a simplified manner. I then work along with you to solve it first using a Brute Force approach, and then an efficient approach. All along with visuals and explanations.
00:00 - Intro
00:29 - Problem Statement and Test Case
02:15 - Brute Force Method
04:15 - Optimized Solution
07:10 - Dry-run of code
đ Links I talk about in the video:
Actual problem on LeetCode: leetcode.com/problems/maximum...
Code on Github: github.com/nikoo28/java-solut...
Test cases on GitHub: github.com/nikoo28/java-solut...
đ A text based explanation is available at: studyalgorithms.com/array/max...
Kadane's algorithm: en.wikipedia.org/wiki/Maximum...
To see more videos like this, you can show your support on www.buymeacoffee.com/studyalg...
đ» Get Social đ»
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
#leetcode #programming #interview
The explanation is so good!
Thanks brother
Hey, Your awesome, Please do more videos on frequently asked questions .Please do more content you will get million subscriber's because your content and white board, practical code walk is awesome. Once content grows more you will start to see many subscribers because we like your explanation. I just told my whats app group friends and they will subscribe soon.
Thanks for all the support. To add more and more questions I do take requests. You can dm me or just tell me the question in comments.
I too wish I could make more frequent videosâŠbut donât want to do any compromises on the quality. Thanks for sharing the video to your friends.
This really motivates me.
Thank you so much. Your videos are really helpful for me in understanding how to approach these problems.
You're very welcome!
Thank you so much sir
awesome brotherâ€ïž
Thanks
Thank youđ
why are we taking values from 3 (4th index) on wards (right to left) why not we start with 2nd and 3rd indices is there any reason for that
Thanks brother.
The explanation is great and your dynamic programming playlist is awesome.
One question:
What if we are asked to find that subarray start and end indexes as well ?
How we will find ?
you will need to keep a track of those indexes. try to write a pseudocode for it
why is the sum of the lone element -2, 2? at 3.27
I misspoke over there. The sum of the alone element would be just '-2'
I'm afraid of this problem because of it's name "Kadane's Algorithm" ... After ur video I went to GeeksForGeeks and solve this also solved it in Leetcode...
Thankyou so much!!... I thought DSA is very hard for me..But ur explanations made it very easyy!!
did not get it pls explain
Which part are you having trouble in understanding? I can help you out.
hey sir why i=1 we get a -7
please point me to the timestamp you are having a problem with
Hello sir, where i can find this problem in leet code
The link is always available in the description.