DP 54. Partition Array for Maximum Sum | Front Partition 🔥

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 207

  • @nagatanujabathena6319
    @nagatanujabathena6319 2 роки тому +26

    Just an update : The problem link in the description points to a different question.
    Thanks a lot for providing such a valuable content for free!

  • @rupamhari115
    @rupamhari115 2 роки тому +88

    You taught the entire DP series so well.. that I solved both front partition problems by my own from Recursion to Tabulation, and then I am seeing this video to increase views count and also to know your approach.
    Thank you so much bhaiyaa ❤❤❤❤

    • @PiyushSharma-ud9qk
      @PiyushSharma-ud9qk 2 роки тому +3

      Same bhai same😌😌

    • @rupamhari115
      @rupamhari115 2 роки тому +1

      @@PiyushSharma-ud9qk 😀😀

    • @gandhijainamgunvantkumar6783
      @gandhijainamgunvantkumar6783 2 роки тому +11

      I was going to directly watch the video, but when I saw your comment I stopped the video and tried the problem by myself and I solved it in the first attempt only without any wrong answer. Thanks for motivating me to try by myself 😄😄😄

    • @rupamhari115
      @rupamhari115 2 роки тому +1

      @@gandhijainamgunvantkumar6783 great.. ❤️😎

    • @gandhijainamgunvantkumar6783
      @gandhijainamgunvantkumar6783 2 роки тому

      @VIVEK YADAV amazing 🔥

  • @yashkhatwani3198
    @yashkhatwani3198 Рік тому +8

    Understood and completed the entire series. This is the best series till now. Love you keep contributing for community

  • @sarthaksharma6973
    @sarthaksharma6973 2 роки тому +40

    Solved this problem Completely on my own thanks a ton for this series. Wished this series came much earlier I won't have to struggle in dp a lot. Kudos to content creators like Kartik arora and striver.

  • @stith_pragya
    @stith_pragya 10 місяців тому +6

    I too solved this problem on my own but checking the video to increase view count + to know Striver Bhaiya's code........This A2Z Sheet is just amazing........words are not sufficient to justify its appreciation.................Thanks a ton Striver Bhaiya.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @AniRec-e8u
    @AniRec-e8u Рік тому +3

    solved this problem completely on my own thanks to your series it took me some time getting the partition and sequencing question but once i got it , it was amazingly easy.

  • @Noob_Coder1234
    @Noob_Coder1234 8 місяців тому +2

    JUST ONE MONTH BACK FRO TODAY THIS QUESTION WAS ASKED IN LEETCODE'S DAILY QUESTION AND I LEAVE IT BECOZ I DID'NT EVEN KNOW WHAT THE DP IS FROM NOW I SOLVE THIS QUESTION WITHOUT WATCHING SOLUTION IN RECURSIVE + MEMOZIATION + TABULATION METHOD JUST BECAUSE OF THIS GOAT MAN AND TEACHER STRIVER♥

  • @stith_pragya
    @stith_pragya 10 місяців тому +2

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

  • @anujrathore5726
    @anujrathore5726 4 місяці тому +1

    did that que by myself , thankyou striver for this gold dp series .

  • @codingProfile449
    @codingProfile449 3 місяці тому

    was able to solve this problem on my own. Thanks striver for teaching the entire dp series so well.

  • @raunakagarwal8284
    @raunakagarwal8284 Місяць тому

    was able to solve this question on my own . Thankyou Striver

  • @tasneemayham974
    @tasneemayham974 Рік тому

    To the world you are a teacher. TO YOUR STUDENTS YOU ARE A STARRR!!!!
    UR the best bro!

  • @simarpreetsingh7235
    @simarpreetsingh7235 3 місяці тому

    Legendary Playlist, Thank you so much!

  • @sameersahu4569
    @sameersahu4569 2 роки тому +2

    Wrote the code all by myself..all thanks to you
    Understod!!

  • @UECAshutoshKumar
    @UECAshutoshKumar 4 місяці тому +1

    Thank you
    Understood!!!

  • @dudeyouhavenoidea
    @dudeyouhavenoidea 9 місяців тому

    Awesome solution and great explanation

  • @ritikshandilya7075
    @ritikshandilya7075 3 місяці тому

    Thankyou for amazing solution Striver

  • @allaboinadivakar1976
    @allaboinadivakar1976 5 місяців тому

    understood very clearly thank you striver.

  • @mriduljain6809
    @mriduljain6809 Рік тому +1

    Was able to solve the problem on my own.
    All thanks to you Bhaiya.. You have made DP very simple
    As always "understood"

  • @sharmilasiram5438
    @sharmilasiram5438 6 місяців тому

    Solved this on my own! thank you so much

  • @shivamtiwari20028
    @shivamtiwari20028 2 роки тому +2

    Solved this problem on my own
    Thankyou so much striver ❤

  • @ntgrn-pr5yx
    @ntgrn-pr5yx 11 днів тому

    thank you understood , striver

  • @DevashishJose
    @DevashishJose 9 місяців тому

    Understood, Thank you so much Striver.

  • @Hrushi_2000
    @Hrushi_2000 Рік тому

    This is kind of Tricky. Thankyou Sir. Understood.

  • @amanbhadani8840
    @amanbhadani8840 2 роки тому

    Your explanation on topic like front partitions makes this concept super duper easy to understand.

  • @scripter7676
    @scripter7676 Рік тому +2

    Thank you striver just because of you today i am in codenation as an SDE 5

  • @dennyage4791
    @dennyage4791 2 роки тому +2

    Thanks you sooo much sir for teaching us this awsome dp series, i can say this dp playlist is best ever in internet .

  • @ThePurist141
    @ThePurist141 2 роки тому

    Hello, thank you so much sir for the wonderful explanation of this problem, and this is the first time I'm visiting your channel and this being the first video I've watched. Immensely helpful in understanding the working of the logic and the code.
    Thanks a lot

  • @KeigoEdits
    @KeigoEdits Місяць тому

    Did on my own! ❣

  • @VivekVerma-oo3dx
    @VivekVerma-oo3dx 10 місяців тому

    i dont know what to say
    i am so dumb in dsa and making the dp problem by my own feels so great bhaia ..

  • @prabhakaran5542
    @prabhakaran5542 4 місяці тому +1

    Understood❤❤❤

  • @hackytech7494
    @hackytech7494 Рік тому

    How can you explain this problem so easily ♥Thanks a lot.

  • @parasgupta1391
    @parasgupta1391 9 місяців тому

    Kya explaination the waaaaaaaaaah!!!!!!!!!1

  • @cinime
    @cinime 2 роки тому

    Understood! Sooo amazing as always, thank you very much!!

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 Рік тому +1

    Awesome series

  • @RohitKumar-dy2gc
    @RohitKumar-dy2gc 11 місяців тому

    hurray! i solved this ques by myself 😊

  • @akashpal7748
    @akashpal7748 Рік тому +1

    understood😀

  • @crazyduniya128
    @crazyduniya128 Рік тому +1

    you can also get the length as j - ind + 1

  • @PriyanshuKumar-wu4wk
    @PriyanshuKumar-wu4wk 2 роки тому +2

    how do we know when we have to use front partitioning?

  • @arihantjammar8888
    @arihantjammar8888 Рік тому

    Understood 😊

  • @surajjoshi3433
    @surajjoshi3433 Рік тому

    What will be the time complexity of recursive approach?

  • @jaividyasagarr7110
    @jaividyasagarr7110 Рік тому

    Solved this problem on my own, Very grateful to you Striver
    Here's my Tabulation approach,
    class Solution {
    public:
    int maxSumAfterPartitioning(vector& arr, int k) {
    int n = arr.size();
    vector dp(n+1, 0);
    for (int i=n-1; i>=0; i--) {
    int ans = INT_MIN;
    int maxy = INT_MIN;
    for (int j=i; j

  • @sparshbarolia1556
    @sparshbarolia1556 Рік тому

  • @ratinderpalsingh5909
    @ratinderpalsingh5909 Рік тому

    Understood, sir. Thank you very much.

  • @verma_jay
    @verma_jay Рік тому

    understood

  • @premduvvapu476
    @premduvvapu476 Рік тому

    Understood

  • @mohitaggarwal6220
    @mohitaggarwal6220 Рік тому

    I have a doubt in 2 questions, like in MCM question we take dp as f(i, j) --> consider what will be the answer if array is from (i to j) and here we just reduces our time complexity, and make the problem into f(i) --> what will be the answer if array starts from ith index. so can we reduce MCM problem into front partitioning problem ? If not then why?? what is the main restriction for which we can't do that problem in front partitioning manner?

  • @adebisisheriff159
    @adebisisheriff159 10 місяців тому

    Understood!!!

  • @dhanashreegodase4445
    @dhanashreegodase4445 8 місяців тому

    what will be the TC of recursive solution without memoization?

  • @ujjalsaha428
    @ujjalsaha428 2 роки тому +3

    As always "understood" ❤️

  • @Hemus212
    @Hemus212 2 роки тому

    understood, very well explained

  • @ueditz6807
    @ueditz6807 2 роки тому +5

    Problem link given ..is not correct 🙂

    • @Truysジャ
      @Truysジャ 2 роки тому +2

      Do u know the correct problem link, can u pls share if u have.

    • @coding8000
      @coding8000 2 роки тому +1

      yes, its wrong, please send the correct one.

    • @vaibhavkumar526
      @vaibhavkumar526 2 роки тому +3

      Here you go: leetcode.com/problems/partition-array-for-maximum-sum/

  • @kunalrastogi6530
    @kunalrastogi6530 Рік тому

    can we apply greedy?

  • @mohammedsuhail8706
    @mohammedsuhail8706 2 роки тому

    Isn't this unbounded knapsack?

  • @soubhikghosh6564
    @soubhikghosh6564 Рік тому

    Bhai this man is a god of DSA literally!

  • @adityasaxena6971
    @adityasaxena6971 Рік тому

    Understood Striver , Thanks a lot

  • @bakyt_yrysov
    @bakyt_yrysov Рік тому

    Thank you so much!!

  • @rishabhgupta9846
    @rishabhgupta9846 Рік тому

    Understood,able to solve by myself

  • @rameshpokhriyalnishank7445
    @rameshpokhriyalnishank7445 2 роки тому +1

    As always "understood" ❤

  • @vaibhavkumar526
    @vaibhavkumar526 2 роки тому +27

    Problem link: leetcode.com/problems/partition-array-for-maximum-sum/

  • @AmitRanjan-xt2th
    @AmitRanjan-xt2th 9 місяців тому

    @Striver Bhaiya - Why not -1 to answer as like previous Question i.e Palindrome Partioning-2 ,here also we going to last element

  • @UtkarshSharma-f1c
    @UtkarshSharma-f1c Рік тому

    Great video

  • @awkward_adi
    @awkward_adi Рік тому

    Can anyone Explain how to differentiate between front partition and mcm type problems?

  • @ganeshkamath89
    @ganeshkamath89 2 роки тому

    Thanks Striver. Understood.

  • @Harshit126
    @Harshit126 2 роки тому

    Understood, thanks

  • @mihirsaini592
    @mihirsaini592 Рік тому

    THANK YOU SIR.

  • @parshchoradia9909
    @parshchoradia9909 Рік тому

    Understood SIr!

  • @shivanshusingh5391
    @shivanshusingh5391 Рік тому

    Thanks a lot

  • @faizansiddiqui753
    @faizansiddiqui753 3 місяці тому

    Can someone answer this question Why can front partition logic cannot be applied in minimum cost to cut stick, burst balloons, evaluate boolean expression??

  • @amitrawat8879
    @amitrawat8879 Рік тому

    Bhaiya why we used ind+k because isse toh range badhti chli jayegi hrr iteration mai, toh wo 3 elements ko he kese select karega. (For k = 3)

  • @amitrawat8879
    @amitrawat8879 Рік тому

    Bhaiya why we used ind+k because isse toh range badhti chli jayegi hrr iteration mai, toh wo 3 elements ko he kese select karega. (For k = 3).

  • @nehapol9862
    @nehapol9862 2 роки тому

    Best explanation ever

  • @sayandey1131
    @sayandey1131 Рік тому

    How to know when to go for Front partition and when to go for normal partition DP like MCM?? ...I am having a bit of difficulty in understanding this.

  • @akashsahu2571
    @akashsahu2571 Рік тому

    yes

  • @vikneshcs4824
    @vikneshcs4824 3 місяці тому

    Would the number of partitons exceed k here

  • @rishupatel7285
    @rishupatel7285 2 роки тому

    Tried to solve it differently be declaring a 3D DP although it gave TLE at40/52 TC.

  • @gsampath8017
    @gsampath8017 2 роки тому +1

    Thanks striver❣️

  • @vibhujain4134
    @vibhujain4134 2 роки тому

    Understoooooooooooooooooooooooooooooooooooooooooodddddddddd!!!!!!!!!!!

  • @YashveerGahlot-t6b
    @YashveerGahlot-t6b 2 місяці тому

    "understood"

  • @yeswanthh5068
    @yeswanthh5068 2 роки тому +1

    Understood 🙂🙂💚

  • @dharsan.s7937
    @dharsan.s7937 2 роки тому +1

    is dp playlist completed ?

  • @mohdkhaleeq7468
    @mohdkhaleeq7468 Рік тому

    understood bro great explanation

  • @satyampande684
    @satyampande684 2 роки тому +4

    understood!!
    Codestudio Problem Link - www.codingninjas.com/codestudio/problems/maximum-subarray_3755255

  • @suhaanbhandary4009
    @suhaanbhandary4009 Рік тому

    understood!!

  • @gangsta_coder_12
    @gangsta_coder_12 2 роки тому +1

    UNDERSTOOD

  • @rohalkurup1350
    @rohalkurup1350 2 роки тому

    Understood !!!!!!!!!!!!!!!!!!!!!!!!

  • @U2011-n7w
    @U2011-n7w Рік тому +1

    why space optimization is not working here

    • @vishious14
      @vishious14 10 місяців тому

      Because we’ll need atmost “k” independent arrays and not two. That being said, we can optimize this using “k” number of arrays.

    • @blitzkrieg7453
      @blitzkrieg7453 5 місяців тому

      @@vishious14 actually dont we just need k number of variables to space optimise instead of arrays as you mentioned!

  • @samyakjain7422
    @samyakjain7422 2 роки тому

    understood!!!!!!!

  • @Ashwani_sharma
    @Ashwani_sharma Рік тому

    Can anybody please tell me how to shift all selected lines(shortcut) as done at 20:22

  • @tusharrustagi5729
    @tusharrustagi5729 2 роки тому

    understood

  • @VikashYadav-px8ei
    @VikashYadav-px8ei Рік тому +1

    Understood 🎉

  • @avisoft-l2p
    @avisoft-l2p 3 місяці тому

    US bhaiyaa

  • @iamnoob7593
    @iamnoob7593 10 місяців тому

    US striver

  • @aakashrockster8576
    @aakashrockster8576 Рік тому

    I solved this on my own

  • @ankushroy5606
    @ankushroy5606 2 роки тому +2

    can't we apply greedy like which element is maximum give him maximum space left

    • @altamashsabri8142
      @altamashsabri8142 2 роки тому +1

      No......take example:- [ 1 15 13 4 4 1 ] k=3
      By greedy we would want to give 15 , space of 3 means [ 15 15 15 4 4 4 ] sum=57
      But [ 15 15 13 13 13 1 ] sum= 70 which is maximum you can get

  • @aditithakur6226
    @aditithakur6226 Рік тому

    Understood Sir.

  • @RimoGhosh-p5b
    @RimoGhosh-p5b Рік тому

    Why aren't we using 2D dp for this problem? Can Anyone plz explain.

    • @krat9707
      @krat9707 Рік тому

      cuz we only need the max of the 3 partition we do so storing only that maximum is useful

  • @ashwanisharma8903
    @ashwanisharma8903 2 роки тому

    understood. Super

  • @pranayreddy5824
    @pranayreddy5824 2 роки тому

    If anyone have problem link please share

  • @giraffe4375
    @giraffe4375 2 роки тому

    Thanks striver