i just came to your video , i am afraid about DSA , Now i just see that video and now i am confident that i can also solve the problems, your way of teaching is quite simple and easy. thanks a lot.
This was an amazing example sir, if we wanted we would have made this code a lot more heavier and complex. Increasing its complexity. But your video showed us an follow process to make the code optimal and reduce the complexity to lowest possible.
Even if we are asked for size of longest subarray which yields the max sum , we can use Concept of Variable size window to find the sum(mx sum using kadane ) . Time => O(n)
@@Asad-pq7el take a vector sum and intial array of size n, then go i = 0->n, where there's a var x = 0 & max = 0 then run j = i -> n, where x += arr[j] and if arr[j] beginner than max update it and also store the i & j index in another var a,b.. after the whole iteration is completed, you'll have a, b which is the starting & finishing index of the longest subarray with max sum..
so nice to see someone who can explain things just as easy as this, I understood everything concept he explained while I can speak nor hear a single word in indian language, imagine if he were speaking in English 🤣🤣, a great teacher always finds a way to make students understands what he means. Thanks India for producing such indian talents.
Some Nigaa Said "This was an amazing example sir, if we wanted we would have made this code a lot more heavier and complex. Increasing its complexity. But your video showed us an follow process to make the code optimal and reduce the complexity to lowest possible."
jab koi video khojta hu kisi topic se related aur agar aapka dikh jata hai to suprise milta hai ek bara wala. aur mera man Doubt ko kehta hai "Ab to tu gaya beta"
Bhaiya, A suggestion for Dsa series-- Could you please create a schedule kinda like when to start when to end what , An excel sheet or something where we can enter our start date nd the rest dates will b decided logically for whole dsa plan ,this will give us a fair idea of which vdo/homework/tasks should take what time for completion. We can stick to that and try to complete the course within the deadlines as mentioned in the sheet. Problem in self is that we don't get an idea how much to do each day or how to allocate number of days to each topic,thus we exaggerate the things without proper plan leading to non completion of tasks
Thankyou bhaiya, I understood it clearly now...😄 I wanted to ask that will us be ever able to actually make these kind of algorithms ourseleves? Like learning sliding windows, kadane's algo and other algos is different thing and making them is different.
To actually make algorithms you can do your research/phd in algorithms. These algorithms were made in budding days of computer science and algos are mainly build by mathematicians. Like this kadane algo was made in 1980s
@@sirkartik I hardly believe that any developer is building some amazing algorithms in their day to day job. No dev will write a new algo. Even if you make a decent algorithm in a project codebase on your own but it won't be approved by your seniors if some standard algo is out there. If you are interested about making algorithms you can opt for MS/PHD in CSE and can take your thesis as Algorithms. To discover new things you need to pursue research.
Any upcoming live web development batches? Your TH-cam content has been super helpful, but I want to try a live class for a more interactive learning experience. Let me know if you have any plans or updates. Thanks!
third step needs more explanation why we need to make sum 0 if sum becomes -ve anuj bhaiya have explained it well if some one does not understand please checkout his video once.
Bhaiya if possible can you start series on solving your 450 Dsa cracker sheet If you provide a bit overview of the problem also then it will be very much helpful as your explanation is excellent Thank you bhaiya 🙏
The also doesn't work for negative numbers, You need different algorithm. Following is the working implementation in Javascript: function maxSubArray(nums) { let maxSoFar = nums[0]; let maxEndingHere = nums[0]; for (let i = 1; i < nums.length; i++) { maxEndingHere = Math.max(nums[i], maxEndingHere + nums[i]); maxSoFar = Math.max(maxSoFar, maxEndingHere); } return maxSoFar; }
i just came to your video , i am afraid about DSA , Now i just see that video and now i am confident that i can also solve the problems, your way of teaching is quite simple and easy. thanks a lot.
Nooooo one can explain better than him...Thank you Sir for such an easy explanation
When you study great teachers… you will learn much more from their caring and hard work than from their style. TQ sir
This was an amazing example sir, if we wanted we would have made this code a lot more heavier and complex. Increasing its complexity.
But your video showed us an follow process to make the code optimal and reduce the complexity to lowest possible.
You are going to revolutnize the coding universe....💯💯
love from nepal..🥰
Even if we are asked for size of longest subarray which yields the max sum , we can use Concept of Variable size window to find the sum(mx sum using kadane ) . Time => O(n)
bhai 2 loop use karke all subarray kaise nikal sakte hai?
@@Asad-pq7el take a vector sum and intial array of size n, then
go i = 0->n, where there's a var x = 0 & max = 0
then run j = i -> n, where x += arr[j] and if arr[j] beginner than max update it and also store the i & j index in another var a,b..
after the whole iteration is completed, you'll have a, b which is the starting & finishing index of the longest subarray with max sum..
so nice to see someone who can explain things just as easy as this, I understood everything concept he explained while I can speak nor hear a single word in indian language, imagine if he were speaking in English 🤣🤣, a great teacher always finds a way to make students understands what he means. Thanks India for producing such indian talents.
explained from basics, so best explanation ever thank uuuu😇
One of the most important approach for the complex problem of array.
Thank you bhaiya ....just isko sikhne ke bad maine lagatar 2 questions solve kar di with some modifications for different problems
170 Bhaiya aapke ecplainations ki etni aadat hui hai ki ab baki khi se bhi padho kuch samj nahi aata
Besttesstttt explaination & Bhaiyaaaa Everrrr😍
The playlist that I've been searching all over the internet and finally you started it.., thankyou for making it❣️
Nice Man just opened my concepts crystal clear
Ek baar mein hi samjh aa gaya thanks mahan guru ji 😊
Some Nigaa Said "This was an amazing example sir, if we wanted we would have made this code a lot more heavier and complex. Increasing its complexity. But your video showed us an follow process to make the code optimal and reduce the complexity to lowest possible."
jab koi video khojta hu kisi topic se related aur agar aapka dikh jata hai to suprise milta hai ek bara wala. aur mera man Doubt ko kehta hai "Ab to tu gaya beta"
Simply great explanation, great bhaiya 🔥🔥🙌🙌
most valuble content bhaiya majaa aa gya
😀😀
Wonderful explanation.... did't know that. it is that much easy.
Another game changing playlist started...kudos to you sir...DAY 1 ✅
Efforts >>>3 man ❤️
Bhaiyya ,love the video and solution,
Please upload the lecture on-
"sliding windows algorithm"
Best Explanation bhaiya
Bhaiya swad aa jaata haii apki video dekh k❤💯
Thank you so much sir nice explanation and easy to understand ❤️
thankyou bhaiya for easy and to the point concept of kadane's algo.
bhoat time se wait kr Raha tha ..
I have gone through multiple videos none of them helped me to understand Kandane's algorithm. This video does
top notch explanation !
truly the best explaination
Thank You Bhaiya for Completing the Remaining Algorithms
Ye bari achi initiative liya hai aapne bhaiya 👍👍
majaa aa gyaa bro. keep it up!!
Pls add this video in DSA series playlist, I didn't knew about this algo for maximum contiguous product.
Thank you so much bhaiya😁❤️
So much love to you
good explanation bhaiya
Bhaiya,
A suggestion for Dsa series--
Could you please create a schedule kinda like when to start when to end what ,
An excel sheet or something where we can enter our start date nd the rest dates will b decided logically for whole dsa plan ,this will give us a fair idea of which vdo/homework/tasks should take what time for completion.
We can stick to that and try to complete the course within the deadlines as mentioned in the sheet.
Problem in self is that we don't get an idea how much to do each day or how to allocate number of days to each topic,thus we exaggerate the things without proper plan leading to non completion of tasks
i agree!!
thanks bhaiya you made dsa easy for me
Amazing Explanation Sir
You found the sum but which sub array produced that highest sum was not shown in code. How do we highlight which sub array has the highest sum?
understood the concept thank you babbar bhai
Kudos to your hardwork 👏
Achha lga app ka btane ka trika ♥️
mst samjaya bhaiya
Thankuu bro... For your efforts..❤🙏
Hello Jiii ...web development course kabhi upload honge bhaiya ?Excited to learn web development from ur end...
great explanation! thank you for this
Nice explanation sir ......
Thankyou bhaiya, I understood it clearly now...😄 I wanted to ask that will us be ever able to actually make these kind of algorithms ourseleves? Like learning sliding windows, kadane's algo and other algos is different thing and making them is different.
To actually make algorithms you can do your research/phd in algorithms. These algorithms were made in budding days of computer science and algos are mainly build by mathematicians. Like this kadane algo was made in 1980s
@@rohanverma3111 Thanks for the info brother👍
@@rohanverma3111 I want to ask that do developers make algorithms or they just see it from somewhere, or learn it and only implement it?
@@sirkartik I hardly believe that any developer is building some amazing algorithms in their day to day job. No dev will write a new algo. Even if you make a decent algorithm in a project codebase on your own but it won't be approved by your seniors if some standard algo is out there. If you are interested about making algorithms you can opt for MS/PHD in CSE and can take your thesis as Algorithms. To discover new things you need to pursue research.
superb , thanks a lot .
9:37 agar sum = -1 aya,then max(-1,-2) = -1; to hum kiu sum ko ignore kare jaab sum 0 se kam aye??
thank you sir 👌👌👌👌
Bhaiya plz make videos on rabin karp algo and kmp algo
sir mazza aa gya 😊
You made it easy thank you 😌
if all the element in the array is -ve then apply this
long long maxSubarraySum(int arr[], int n){
long long max = arr[0];
long long sum=0;
for(int i=0;imax)
max = sum;
if(sum
Thanks for new vedio Babbar
nice explanation
Amazing explanantion.
Kudos to your effort :)
Best Explanation
Thank you sir
Thanks I was stuck at this program from last 3 days,sab ho gya tha sum
amazing explanation!!!!!!!!!
Great Explanation
Any upcoming live web development batches? Your TH-cam content has been super helpful, but I want to try a live class for a more interactive learning experience. Let me know if you have any plans or updates. Thanks!
Guruji dhanyavaad
KMP Algorithm next pls??🙃
Han bhaiya kmp algorithm please upload the video
very easily described
Best explanation
Segtree wen?
Algo samjha diya apne code khud karunga😂
third step needs more explanation why we need to make sum 0 if sum becomes -ve anuj bhaiya have explained it well if some one does not understand please checkout his video once.
Wa Bhai ❤
Thank you so much sir
// COMPLETE CODE
class Solution {
public:
int maxSubArray(vector& nums) {
int sum = 0;
int maxi = nums[0];
for(int i=0; i
Doesn't work on all negative numbers. I have to search correct Kadane's also.
anyone explain the second approach in o(n^2) time complexity
Bhaiya if possible can you start series on solving your 450 Dsa cracker sheet
If you provide a bit overview of the problem also then it will be very much helpful as your explanation is excellent
Thank you bhaiya 🙏
Yeah it's needed
Yes , it will be helpful.
Bhaiya please two pointer approach and sliding window algo ko bhi cover kr do
Sir ,
What if all the elements were negative....so in that case, how could we implement the condition for less than 0
did you get the answer ?
@@Griffith_1802 some has mentioned this code:
function maxSubArray(nums) {
let maxSoFar = nums[0];
let maxEndingHere = nums[0];
for (let i = 1; i < nums.length; i++) {
maxEndingHere = Math.max(nums[i], maxEndingHere + nums[i]);
maxSoFar = Math.max(maxSoFar, maxEndingHere);
}
return maxSoFar;
}
I guess you need to check if all elements are negative then return smallest negative else run kadane's algo.
we can check first that all the number are negative , then return the largest number...
Thankyou for this video bhiaya
Bhaiya if all elements are negative then how we will treat this question
Bhut achha pdhate hai bhaiya aap
It is handled in the case where maxi =arr[0]
Because Atlast we are simply returning maxi.
Bhaiya, can you share 2nd approach with time Complexity O(N2) .I just want to cross Verify my code ...
can you pls ur code
share
If the array contains all negative integers than what will be the sum? since here u are excluding all the negative sum,,
Patra Korsani is a God 👑
Because he understood this algorithm even though he doesn't know ABCD
New series algorithms hurray 🙂
Hi ..If we want to print the specific sub array with largest sum then what needs to be done
Starting and ending index nikal le
if we consider all +ve integer in array then max sum should be 12
The also doesn't work for negative numbers, You need different algorithm. Following is the working implementation in Javascript:
function maxSubArray(nums) {
let maxSoFar = nums[0];
let maxEndingHere = nums[0];
for (let i = 1; i < nums.length; i++) {
maxEndingHere = Math.max(nums[i], maxEndingHere + nums[i]);
maxSoFar = Math.max(maxSoFar, maxEndingHere);
}
return maxSoFar;
}
Thank you bhaiya
doesnt work if all numbers in array are -ve, maxi will return a negative integer rather than returning 0.
Can anyone tell me ans for maximum subarray sum for
[2,0,7,8] using the above algorithm
please
What if we dont need maximum sum but instead want those subpairs which make maximum sum???
Sir,According to me you cannot get all the subarrays from only 2 loops which you have used ! if so please anyone clear my doubt!
Best teacher
Waiting for long time, ab to placement pkki
Prefix sum algorithm ki bhi video bnaeye
thankyou sir
Nice lecture
Please make a video on Tower 🗼 of Hanoi on recursion