Find The Maximum Subarray Sum ( LeetCode #53 ) | FREE DSA Course in JAVA | Lecture 75
Vložit
- čas přidán 26. 07. 2024
- Let's see a popular Leetcode question number 53. In this program we have to find the maximum subarray sum.
What does this mean?
Given an integer array nums, find the maximum contiguous subarray (containing at least one number) which has the largest sum and return the sum.
For eg. [1, -2, 3, 4] is the array then the answer will be [3,4] and the output will be 7.
Now as we always do in all our lectures. Let's understand a naive approach.
We already know how to find the subarrays of a given array.
Hence we can find the sum of all subarrays and can return the maximum sum.
This approach will surely work but it's not efficient.
Let's see in this lecture how we can find a more efficient approach to solving this program.
For more information, fill out this form: forms.gle/8eiUmM92Fx563Aen9
or call us at 8884881203
Facebook: / thetapacademy
Instagram: / tapacademy_online
Linkedin: / 73820805
Website: www.thetapacademy.com
#java #array #programming #programmer #coding #dsa #placement #job #itjobs
thanku sir for simple explanation
Thanks a lot Sir
Thank you so much for the Topic understood the Concept in a ease
Rohit sir after listening to your logic no need to see the code we can write it ourselves.Thanks soo much for beautiful explination.
That's great. We are trying to deliver you the best content. Do subscribe and share the channel.
Thankyou so much. The explanation was superb
Thank you bhaiya😃😃
Your video on DSA in Java was truly exceptional! Your clear and concise explanations, coupled with visually appealing graphics, made learning complex algorithms a breeze. You are a master of your craft, and it was a pleasure to watch.
Glad you liked it! Please share it to your community.
i dont know some miracle happend i understood this problem very easily
GOAT❤❤❤
what a teaching style ... love form bangladesh
Hahaha the best video I found for this max subarray peoblem.
W explanation
Sir, your teaching is just wow wow wow
I tried to watch so many videos but nobody explain better then you thanks alot sir i subscribed you
What if len(arr) == 1. For ex: if I have 1 element in arr, i.e [1] then the maxSum would be 2 (sum = sum+arr[i]). We need to cover this case as well
Good explanation sir
Keep watching and do share our channel in your community.
i love you man. nobody will explain the way you explain
Hands off 🎉🎉🎉 sir , no words to describe your level of teaching 🎉🎉🎉🎉
Excellent explanation sir
You made DSA easy to understand. Excellent video!
God complex teaching skills , MAD RESPECT 🙏
thnaks for the help
@TAP ACADEMY
actully i learn lot of topics from your channnel
but here u should take -> sum value as (0),, other wise it will add sum's value with max_sum's value and give the wrong answer
Thanks
You are fantastic. It could have never been easy. Thanks so much.
Amazing explanation!!! SUBSCRIBED!!!!
Awesome ! explanation sir
Sir your teaching speed resonates with my interpreting speed
I loved the way, he is explaining. A unique way of teaching, which is more understandable. Thank you, sir.
Superb ..Unique way of teaching 👏👏
thank you so much sir,you are explaining very well
what a explanation sir. Easiest one.
wow such a great explanation
Such a good explanation
thank you soo much sir❤
Very very good explanation
Hats off, I have become fan of you teaching bro 🙏
The best sir to teach the coding and to understand it
Thank you sir
Nice clear explanation ❤
Excellent explanation
Sir Your Explanation is WOW Thankyou so much Sir ❤
Wonderful session sir ..
Thanks soo much ..
Always welcome. Do subscribe to the channel.
Thank you is all I can say
Watched many videos to understand the intuition behind it........but this is by far the best explanation for kadane's algo....rohit sir🤙🔥
thanku sir you solve my dry run problem very well:)
You got subscriber. Thanks.
coolest Explanation ever!!period
\
Sir plz continue the lectures sir humble request🙏
209. Minimum Size Subarray Sum please make video on this leet code question
Nice explanation sir 🎉❤❤
Sir I have no words to put up you are just amazing and I'll start watching the whole series from beginning, maza aagaya dekh k so curious to watch this playlist from beginning though I know most of the concepts. Amazing delivery of the content!!!
loved ur level of teaching ... very well explained sir 😁😁
Superb sir❤
The best video ever seen
Sir ur way of explanation is very easy to understand .
Thanks and welcome. Subscribe to the channel for regular tips.
OMG you are genius man
How are you inside the computer😭
Best explanation sirr ❤ well said about Gujaratis 🥂😎
Beautiful masterful glorious ❤❤
sir please upload questions on substring and hashmap
Sir please update the next videos .
You have not applied the videos from 2 days .
There was some problem. From today we will upload lectures again and will cover two lectures per day to cover up the missed classes.
Thank you so much sir for your beautiful teaching style
hi im plusone student usefull videos thanks bro
Happy to help
Now waiting for majority element
sir you are not uploading videos in last 2 days why
There was some problem. From today we will upload lectures again and will cover two lectures per day to cover up the missed classes.
Sir plz explain max triplet sum sir
❤
class Solution {
public int maxSubArray(int[] nums) {
if (nums == null || nums.length == 0) {
return 0;
}
if(nums.length == 1){
return nums[0];
}
int sum = nums[0];
int maxSum = nums[0];
for(int i=1;i= 0){
sum += nums[i];
}else{
sum = nums[i];
}
if(sum > maxSum){
maxSum = sum;
}
}
return maxSum;
}
}