330. Patching Array | Greedy | Array | Math | Why not Bitset Trick

Поделиться
HTML-код
  • Опубликовано: 22 ноя 2024

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

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

    How to balance College & CP - ruclips.net/video/79rxV2d86ww/видео.html

  • @samplayz9557
    @samplayz9557 5 месяцев назад +9

    You and Neetcode are the only people I understand

    • @brij4887
      @brij4887 5 месяцев назад +3

      Good thing that this guy uploads daily, solely responsible for my streak

  • @toxicdemonop519
    @toxicdemonop519 5 месяцев назад +9

    Aryan Bhai Aaj pehli baar leetcode contest mei 4 problems solve kiye, your segment tree video is really great, thanks a lot

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

      can you explain 3 problem i tried with class Solution {
      public:
      bool possible(int p,int check)
      {
      if(p==check-1 || p==check+1 || p==check+2 || p==check-2)
      {
      return false;
      }
      return true;
      }
      long long maximumTotalDamage(vector& power) {
      sort(power.begin(), power.end());
      int maxValue = *max_element(power.begin(), power.end());
      long long pow=maxValue+2;
      vectordp(maxValue + 4, 0);
      for(int i=1;i=0;j--)
      {
      if (possible(power[i-1], j)) {
      dp[j]= max(dp[j],power[i-1] + dp[power[i-1]]);
      }
      }
      }

      return dp[pow];
      }
      }; with this it was giving tle

  • @IK-xk7ex
    @IK-xk7ex 5 месяцев назад +3

    THank you! Your explanation allows to grow analytical skills and setup the way of thinking about the problem. I also discovered that we can reach any `n` if the `prefixSum` of existing numbers more then `n`, but I couldn't code the solution :(

    • @arcade320
      @arcade320 5 месяцев назад +2

      prefix sum find's us subarray sum? but here we can get through any possible combination isn't it?

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

    Superb explanation!! Thank you so much Aryan! 👍

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

    Some simple observation that number such as ((1

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

    Thank you Aryan ❤.

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

    beautiful explanation!

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

    Great Explanation brother !!

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

    Awesome explanation man !

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

    Can you write a bit of a big text

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

    WHY GREEDY WORKS
    _TO PROVE_
    ----> If the greedy algorithm needs to patch k numbers to cover [1,n] it is impossible to patch less than k numbers to do the same.
    _Proof by contradiction_
    let's say for a given value of n and an array nums
    GREEDY gives x1 < x2 < x3 < ... < xk patches (total K patches)
    ANOTHER SOLUTION gives y1

  • @JIGARSINGTHAKOR-yy6qp
    @JIGARSINGTHAKOR-yy6qp 5 месяцев назад +1

    weekly contest problem ??

    • @ARYANMITTAL
      @ARYANMITTAL  5 месяцев назад +14

      Coming sir🫡❤️

    • @PalakKalsi
      @PalakKalsi 5 месяцев назад +7

      Let him breath haha.

    • @JIGARSINGTHAKOR-yy6qp
      @JIGARSINGTHAKOR-yy6qp 5 месяцев назад +1

      @@PalakKalsi he is expert ,so he need to be quick😅

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

    When we add 2 then we can make 3. Now 1 and 3 van make 4 so why you add 4 here

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

    bhaiya dimag kharab hogya ye question samajhte samajhte
    ab pehle iska code likhunga, fir subah uth kr dry rrun krunga 2-3 baar

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

    Great explanation sir !! Saluting your efforts even on Sunday morning !!🫡🫡🫡

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

    🫡🫡🫡

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

    bro your english prickles my ear please work on it or speak in hindi you are so repeatitive man !!! just speak to the point and move on

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

      wtf, he is doing it for free! respect that dumbo