Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing

Поделиться
HTML-код
  • Опубликовано: 31 июл 2024
  • Problem Link: bit.ly/3QhMl6j
    Notes/C++/Java/Python codes: takeuforward.org/data-structu...
    We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
    Full Course: bit.ly/tufA2ZYt
    You can follow me across social media, all my handles are below:
    Linkedin/Instagram/Telegram: linktr.ee/takeUforward
    Time Stamp
    0:00 - Introduction to course
    0:41 - Problem Statement
    2:13 - Brute Force Solution
    6:12 - Better Solution
    7:40 - Optimal (Kadane's Algorithm)
    13:18 - Code
    15:29 - Time Complexity
    15:40 - Follow up question
    19:37 - Outro

Комментарии • 409

  • @takeUforward
    @takeUforward  11 месяцев назад +16

    Please watch our new video on the same topic: ruclips.net/video/AHZpyENo7k4/видео.html

    • @whateverittakes5340
      @whateverittakes5340 20 часов назад

      It's recursion!!!
      lol i kept on clicking the link and its the same link (not recursion but yeah a loop)

  • @lavanyam3224
    @lavanyam3224 5 месяцев назад +117

    13:56 "Do not carry any negatives into your future" - Striver
    Even thought the context was different, it can be applied in our real life❤

  • @takeUforward
    @takeUforward  Год назад +98

    Let's march ahead, and create an unmatchable DSA course! ❤
    Use the problem links in the description.

    • @princejatav8456
      @princejatav8456 11 месяцев назад +1

      bro in case of printing we must have keep track of only last index, think of it,
      bcz if after getting maxsum and startind and endind of subarray , if we further get the sum to be negative and then we put sum=0 and startindex to that index and think if we dont get any subarray that have sum greater than previous one, then we lost our startind and endind of main subarray ,then this will give wrong answer
      so correct solution for it will be keep only track of endind, so next time when we get higher sum then only change it. and after getting maxsum we can easily get our subarray by using last ind, by going on left side of ind and rightside of ind

    • @Nainalarenukadevi9196-dh8rz
      @Nainalarenukadevi9196-dh8rz 21 день назад

      hey is it same for longest subarray sum

  • @chethanprabhu4475
    @chethanprabhu4475 Год назад +86

    Couple of years back, I had watched the best video on RUclips(in terms of views) on Kadanes and still it was not very clear to me. And this video is so so better than the other video. Top level walkthrough.
    P.S: I am not comparing. Else I would have told which video was that which I watched earlier :)

  • @user-cj3zr7pu7t
    @user-cj3zr7pu7t Год назад +1

    Love your explanation of progression of solutions and code walk through. Please keep making precise and amazing content like this. It really helps to stay motivated with solving problems because when I'm stuck, the logic in your vids is explained very clearly. Thanks a lot!!

  • @rpanda_old
    @rpanda_old Год назад +9

    weird how this explanation of kadans algo is so simple compared to other yt videos. short algo short code. superb

  • @3rd_Eye_Gang
    @3rd_Eye_Gang Год назад +21

    Nothing can describe how thankful we're to you for such amazing content.. . God Bless you Striver.. Hope you achieve everything you want ❤️❤️

  • @chaithrac370
    @chaithrac370 Месяц назад +1

    Really amazed by the effort you put into making us understand. Thank you, Striver!

  • @cinime
    @cinime Год назад +2

    Understood! Super excellent explanation as always, thank you very very much for your effort!!

  • @arnavjain762
    @arnavjain762 5 месяцев назад +1

    Complete concept clarity in 20 mins. Amazing ✅✅✅✅

  • @rishabh1S
    @rishabh1S Год назад +87

    Always ready for Dsa ✅

  • @user-mq4fu9yh4t
    @user-mq4fu9yh4t Год назад +1

    bro i really love your explanation ;how ever i explane doudtes to my frnds you explaining in same manner ❤

  • @vaishnaviganseh2884
    @vaishnaviganseh2884 Год назад +2

    BEST Kadane's algo video on the internet!

  • @archanaverma8771
    @archanaverma8771 Год назад

    Your way of explanation is really outstanding🔥🔥🙌thanks lot and more!!!!

  • @yelururao1
    @yelururao1 9 месяцев назад

    i saw many videos but not able to understad.... this video gave me complete understading..Thanks bro

  • @bendivanitha7211
    @bendivanitha7211 Год назад +2

    "Understood " superb intuition of algorithm !! awsome explanation i request everyone whoever watching strivers vedeos do like and comment!!!

  • @Raj10185
    @Raj10185 Год назад +5

    Printing the subarrays part is something i learn this time tysm understood:)

  • @manjamalaimm6178
    @manjamalaimm6178 5 месяцев назад

    Thank You so much for made this crystal clear understanding about this problem.

  • @SurajGupta-gc9tz
    @SurajGupta-gc9tz 8 месяцев назад

    i was very keen about learning DSA and your sheet and your explanation has boosted this thank you strive bhaiya

  • @RaviKumar-sn6tu
    @RaviKumar-sn6tu 4 месяца назад

    in love with kadane algorithm...all thanks to you bhaiya

  • @factfortune2160
    @factfortune2160 6 месяцев назад

    Easiest explaination ever👌👌 thanks bhaiya...!!

  • @syedFAHIM-el1wr
    @syedFAHIM-el1wr Год назад +1

    Crystal Clear Understanding !

  • @piaknow3881
    @piaknow3881 Год назад +1

    Thank you very much bhaiya for these.
    In upcoming videos please add general approach for techniques like sliding window, two pointers etc techniques as the way you give for recursion and dp etc.
    Thank you once again bhaiya

  • @radhakishoriiiiiiiiiii7348
    @radhakishoriiiiiiiiiii7348 8 месяцев назад

    12:28
    very nice explaination. Very helpful walk through that cleared my confusions

  • @stith_pragya
    @stith_pragya Месяц назад +1

    Understood....Thank You So Much for this wonderful video.....🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @sparshverma4030
    @sparshverma4030 Год назад

    understood you are the best teacher. 🙌

  • @VarunKaushal-zx9zq
    @VarunKaushal-zx9zq Год назад +1

    Understood, Amazing Lecture Sir!

  • @Manishgupta200
    @Manishgupta200 Год назад +4

    Kadame's Algorithm is now clear. Thankyou Striver ❤
    From brute(TC -> O(N^3), SC -> O(1)) to better(TC -> O(N^2), SC -> O(1)) to Optimal(TC -> O(N), SC -> O(1))

  • @allegragarland9156
    @allegragarland9156 7 месяцев назад

    Im new to programming and this was very helpful ~

  • @iitmotivationwithrahullson5930
    @iitmotivationwithrahullson5930 Год назад +2

    you are doing great job striver ❤.. .

  • @swagnikdhar6010
    @swagnikdhar6010 Год назад +1

    Absolutely Amazing ✌️🔥

  • @PriyanshuKumar-zd1lq
    @PriyanshuKumar-zd1lq Год назад

    Super explanation with so much love 😃

  • @embarrassed_dodo
    @embarrassed_dodo 17 дней назад

    Very detailed explanation, it is language agnostic as well, thanks for the video

  • @prabalsharma3007
    @prabalsharma3007 8 месяцев назад

    great concepts , understood everything

  • @hareshnayak7302
    @hareshnayak7302 4 месяца назад

    Understood,Thank striver for this amazing video.

  • @samuelfrank1369
    @samuelfrank1369 9 месяцев назад

    Understood. Thanks a lot. Please upload more videos Bhaiyaaa.

  • @Ashishvatsav
    @Ashishvatsav 5 месяцев назад

    Amazing!! Keep going bro⚡

  • @ArunKumar-zp8cp
    @ArunKumar-zp8cp Год назад

    Bro really you have good knowledge of DSA...

  • @shivamsingh-we7ek
    @shivamsingh-we7ek Год назад +2

    i am following this course for my dsa preparation , its an amazing course and explanation by bhaiya
    just want one thing complete this by end of october ♥♥

  • @user-gq6sq8zk8s
    @user-gq6sq8zk8s 6 месяцев назад +1

    Understood!.Thank you.

  • @AyushSharma-ye1xz
    @AyushSharma-ye1xz Год назад

    All videos are very helpful

  • @manipandit18
    @manipandit18 Год назад +30

    Time Stamp
    0:00 - Introduction to course
    0:41 - Problem Statement
    2:13 - Brute Force Solution
    6:12 - Better Solution
    7:40 - Optimal (Kadane's Algorithm)
    13:18 - Code
    15:29 - Time Complexity
    15:40 - Follow up question
    19:37 - Outro
    There's always something new to learn from striver's videos . Thank You bhai for posting videos without any long gap!!!.

  • @tamilmukbang3789
    @tamilmukbang3789 3 месяца назад

    Understood.. thank you so much bro

  • @AmanPandey-bd1sj
    @AmanPandey-bd1sj 9 месяцев назад

    Thanks brother Best Explanation😊

  • @prateekmahajan5490
    @prateekmahajan5490 3 месяца назад

    Understood. Thanks a ton 😇

  • @ITSuyashTiwari
    @ITSuyashTiwari 8 месяцев назад

    simply , loved it....

  • @DevashishJose
    @DevashishJose Год назад

    Understood. Thank you.

  • @tasneemayham974
    @tasneemayham974 10 месяцев назад +1

    BEST TEACHERRRR EVERR!!!!!!!!!!

  • @francksgenlecroyant
    @francksgenlecroyant 10 месяцев назад

    Thanks bro, just subbed to the channel

  • @_hulk748
    @_hulk748 Год назад

    UNDERSTOOD SIR🙇‍♂❤🙏

  • @devipavanlankalapalli7587
    @devipavanlankalapalli7587 7 месяцев назад

    Understood and thanks for the video

  • @lavanyaan2158
    @lavanyaan2158 Месяц назад

    Thank you so much for the video

  • @EC20022ELAKKIYAC
    @EC20022ELAKKIYAC 6 месяцев назад

    Completely Understood!

  • @TheArman_Ansari
    @TheArman_Ansari 7 месяцев назад

    loved it!

  • @AniketKumar-hf2bo
    @AniketKumar-hf2bo 6 месяцев назад

    understood ,thnx for the video ❤❤❤❤❤❤

  • @tulsilukhi1182
    @tulsilukhi1182 2 месяца назад

    Best explanation everr

  • @vaishalidhokchawle4384
    @vaishalidhokchawle4384 3 месяца назад

    Great job👍🏻

  • @saumyapandey8940
    @saumyapandey8940 Месяц назад

    your course is too good

  • @rajindersharma4
    @rajindersharma4 7 месяцев назад

    Understood Boss, it helps !!

  • @torishi82
    @torishi82 21 день назад

    Awesome!!

  • @dasaridharani6529
    @dasaridharani6529 11 месяцев назад

    Incredible 🎉

  • @YerramArun
    @YerramArun Год назад

    Understood ❤bhaiya❤❤

  • @JitendraKumar-ll4lz
    @JitendraKumar-ll4lz Год назад

    Amazing experience

  • @mr_weird3680
    @mr_weird3680 4 месяца назад

    thank you very much brother.

  • @reddygopichand2002
    @reddygopichand2002 9 месяцев назад

    Understood thanks 🙏

  • @suyashshinde2971
    @suyashshinde2971 Год назад +2

    SDE Sheet Day 1 Problem 1 Done!

  • @harshas5462
    @harshas5462 8 месяцев назад

    Understood!!❤

  • @ADITYASINGH-b4u
    @ADITYASINGH-b4u 4 дня назад

    UNDERSTOOD !!

  • @stutidutta3922
    @stutidutta3922 Год назад

    Thanks for explanation

  • @itsabhinav04
    @itsabhinav04 Год назад

    Understood, thanks :)

  • @YourCodeVerse
    @YourCodeVerse 9 месяцев назад

    Understood✅🔥🔥

  • @UECAshutoshKumar
    @UECAshutoshKumar 4 месяца назад +2

    Thank you 🙏

  • @paraschinchalkar1599
    @paraschinchalkar1599 25 дней назад

    amazing video sir

  • @AbdullahKhan-et6qo
    @AbdullahKhan-et6qo Год назад

    Understood 🔥

  • @akofficialss
    @akofficialss Год назад

    Great work

  • @SriSarthak257
    @SriSarthak257 3 месяца назад

    Understood striver! 🔥👍

  • @infernogamer52
    @infernogamer52 Год назад

    Understood bhaiya!

  • @kannan10308
    @kannan10308 2 месяца назад

    Good explanation.

  • @PankajSingh-pb4vs
    @PankajSingh-pb4vs 5 месяцев назад

    Amazing ❤

  • @parshchoradia9909
    @parshchoradia9909 Год назад

    Understood Sir!

  • @banothutharun2743
    @banothutharun2743 5 месяцев назад

    mind blowing sir

  • @adebisisheriff159
    @adebisisheriff159 8 месяцев назад

    Thanks so much striver

  • @naveenkumarchukka4280
    @naveenkumarchukka4280 Год назад

    Thank you!

  • @creativeprojects217
    @creativeprojects217 6 месяцев назад

    thank you sir❣

  • @rajkumarv.b565
    @rajkumarv.b565 Год назад

    Thanks a lot!

  • @mohitsingh13
    @mohitsingh13 2 дня назад

    Understood ❤

  • @hunter-js8hy
    @hunter-js8hy 2 месяца назад

    done and dusted ! hats off to striver ..

  • @HimanshuKhandelwal-rs3hn
    @HimanshuKhandelwal-rs3hn 6 дней назад

    super understood

  • @tarunsingh4413
    @tarunsingh4413 6 месяцев назад +2

    at 15:22 you have to add this code in for loop . if(maxi

  • @RituSingh-ne1mk
    @RituSingh-ne1mk 7 месяцев назад

    Understood!

  • @navkaransinghbrar4380
    @navkaransinghbrar4380 Год назад

    understood
    // first time bro

  • @user-is6ky7pp2n
    @user-is6ky7pp2n 2 месяца назад

    Understood !!

  • @student_03
    @student_03 Год назад

    thank you sir
    understood

  • @ishwardhande1847
    @ishwardhande1847 Месяц назад

    Thanks a Lot

  • @tarishigeetey5430
    @tarishigeetey5430 4 дня назад

    understood !!

  • @forstudycode6146
    @forstudycode6146 11 месяцев назад

    Understand Brother.

  • @suresmishra-5593
    @suresmishra-5593 Год назад

    You the best❤

  • @ashishdhal4614
    @ashishdhal4614 Год назад

    Can't wait for binary search series

  • @culeforever5408
    @culeforever5408 9 месяцев назад +1

    understood 😇

  • @programmingsoul4269
    @programmingsoul4269 Год назад

    Thanks bhaiya 💖💖