Ugly Number II | Simple Explanation | Dry Run | codestorywithMIK

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

КОМЕНТАРІ • 73

  • @hirenjoshi6073
    @hirenjoshi6073 Рік тому +46

    I rarely use to comment on channels, but your channel made me to do so. This is the most amazing tutorial ever found + The Best UA-cam coding channel ever. Seriously! Thank You.... A Heart For You

  • @thekindspill
    @thekindspill 9 місяців тому +5

    You are the best tutor of DSA I have ever seen online.

  • @sunilsarode152
    @sunilsarode152 5 місяців тому +14

    In the middle of explanation, I realise we can use min-heap and i coded it and it works, thanks

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

      Same

    • @vikkasmaheshwari862
      @vikkasmaheshwari862 10 днів тому

      bhai usne intution min heap sol ki di or code dp wala krdiya sbka kat diya

    • @codestorywithMIK
      @codestorywithMIK  10 днів тому

      @vikkasmaheshwari862 Apologies for any confusion. This seems quite an old video. In present, videos, I will ensure to avoid such confusion 😇🙏

  • @akshayrajsingh555
    @akshayrajsingh555 Місяць тому +6

    no. 1 channel in programming 😍

  • @codingdude8718
    @codingdude8718 Місяць тому +1

    man such a good lecture
    very clear and concise explanation

  • @jayshreekarmakar3847
    @jayshreekarmakar3847 Місяць тому +2

    After listening the explanation. I start to do coding myself. Thankyou for your explanations. They are always easy to understand.

  • @atharvpal7038
    @atharvpal7038 10 місяців тому +3

    Great Video mate as usual!!
    You can assume I am binge watching /studying these whenever possible.
    Thanks for the great content! Much appreciated

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

    Next Level Explanation sir........
    Mazaa aaa gyaa

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

    Thanks a lot man for listening to our requests.
    Very helpful . Huge request to you❣

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

    people like u r real gurus!

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

      You, Me and all of us are genius.
      Let’s all grow together and crack together ❤️❤️❤️

  • @aws_handles
    @aws_handles Місяць тому +1

    Big fan here of your teaching ❤

  • @saileshsailesh6979
    @saileshsailesh6979 2 місяці тому +2

    Excellent explanation. Thank you so much 🙏

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

    Beautiful explanation

  • @yatharthgupta6468
    @yatharthgupta6468 Місяць тому +1

    beautiful explanation
    thanks

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

    I did by binary search. BTW,amazing video.

  • @aizad786iqbal
    @aizad786iqbal Місяць тому +3

    1201. Ugly Number III
    313. Super Ugly Number
    I will try these today now..
    btw u should cover it too if u can in your free time..

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

    neat solution as always MIkbhaiya op ❤

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

    The real GENIUS .
    Hats off to your teaching skill

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

    Sir, please make video on Ugly Number III also

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

    Awesome explanation, Thank you!

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

    good tutorial. Looks like there is a lag between explanation and the screen update.

  • @hemant_kumar_071
    @hemant_kumar_071 Місяць тому +1

    Sir , Aap contests ke solution bhi share kroge to bahut help milegi... ❤

    • @codestorywithMIK
      @codestorywithMIK  Місяць тому +2

      Uploading today’s contest Qn-1 and Wn-4
      They are good and will help us learn few things.

  • @gauravbanerjee2898
    @gauravbanerjee2898 Місяць тому +1

    Thanks a lot bhaiya ❤❤

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

    for 263. Ugly Number
    the solution
    is the TC also log n ?
    Constraints:
    -2^31

  • @OmjiKesharwani-b5t
    @OmjiKesharwani-b5t 4 місяці тому

    sir please make video on heap and trie topic videos concept and question playlist plzz plz🙏🙏🙏

  • @KSR05-j8h
    @KSR05-j8h Місяць тому

    do dp fundamentals video and upload as soon as possible bro

  • @CE_113_Katyayni
    @CE_113_Katyayni 2 місяці тому

    Sir can u please make a video on Super Ugly Number of DP Leetcode 313, Its a humble request please make it

  • @rockykumarverma980
    @rockykumarverma980 Місяць тому +1

    Thank you Bhaiya 🙏🙏🙏

  • @chitranshjain9714
    @chitranshjain9714 2 місяці тому

    very nice explanation

  • @OmjiKesharwani-b5t
    @OmjiKesharwani-b5t 4 місяці тому

    sir plzz make video on ugly number 3 video

  • @Lakshya-f4l
    @Lakshya-f4l Місяць тому +1

    Thanks !

  • @shauncrasta619
    @shauncrasta619 7 місяців тому

    Why does i3++ gives the correct next ugly number? Any proof for it?

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

    First of really really nice explanation bhaiya and the dp approach is really 💥💥💥💥💯💯💯💯
    But the reason for taking log base 2 in the time complexity is not that much clear can u explain it bhaiya
    And can u explain me how u are using dp here as far I know dp is using the past result so how are u using it here bhaiya otherwise very nice explanation 🥰🥰🥰

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

      see dp[1] is stored initially right its basically bottom up type
      neeche se solution build karrahe hum
      dp[2] ke liye dp[1] usekiya but wo seeda nai dikra pointers use kiya humne
      and dp[n] depends on min(dp[i_2]*2,dp[i_3]*3,dp[i_5]*5) i_2 i_3 i_5 ye sab n ke less hi honga so we are using the values stored to build the higher solution so its Dp

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

      @@vishalplayzz2580 Thanks a lot

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

    Awesome

  • @Gauravkumar-lv7xd
    @Gauravkumar-lv7xd Місяць тому

    Thanks

  • @KishanSingh-vc3re
    @KishanSingh-vc3re Місяць тому

    aaj k contest ka 2nd answer memoise ni ho rha tha ,pls do it(maximum energy boost from 2 drinks)

    • @codestorywithMIK
      @codestorywithMIK  Місяць тому +1

      Uploading today’s contest Qn-1 and Qn-4
      They are good and will help us learn few things.

  • @parvahuja7618
    @parvahuja7618 3 місяці тому +1

    thankyou sir

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

    Thank you!

  • @CE_113_Katyayni
    @CE_113_Katyayni 2 місяці тому

    bhiaya Super ugly number ka v solution dedo n please

  • @Shubham-kk
    @Shubham-kk Місяць тому

    how are you taking t in 21st line without initializing it?

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

    @19:47 why i3 is pointing to t[2] instead of t[3], can someone explain ? please!

    • @harshsuthar4947
      @harshsuthar4947 Місяць тому +2

      Initially i2 i3 and i5 are 1
      Then we checked
      2*1
      3*1
      5*1
      Among these 2*1 is the smallest hence we update the pointer for 2 i2++ which is (i2=2)
      Now array would have 0 1 2
      Now we would check
      2*2
      3*1
      5*1
      As 3*1 is the smallest we would update the pointer for 3
      i3++ so (i3=3)
      So array would have 0 1 2 3
      Now
      i2=2
      i3=2
      i5=1
      So according to this i3 is currently 2
      So t[i3] should point to 2 and not 3

    • @rohan8758
      @rohan8758 Місяць тому +1

      @@harshsuthar4947 Thanks for the reply, By the way i forget to remove this comment. I got intuition why i1, i2, i3 is just moving forward by one (We need to keep track of minimum ugly number for arr[i]) after watching complete algorithm.

  • @chiragsingh8323
    @chiragsingh8323 11 місяців тому +1

    🔥❤️

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

    what is dp here?

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

    where we are using dp btw

    • @gui-codes
      @gui-codes Місяць тому +1

      May be that's why -
      The approach uses previously computed results (t[i2], t[i3], t[i5]) to avoid redundant calculations.
      The code efficiently handles the problem by storing the minimum values needed for the sequence, ensuring that each ugly number is generated in order.

  • @Rajdweep
    @Rajdweep Місяць тому +1

    ye dp kaise hua yr this looks greedy to me

    • @gui-codes
      @gui-codes Місяць тому +1

      May be that's why -
      The approach uses previously computed results (t[i2], t[i3], t[i5]) to avoid redundant calculations.
      The code efficiently handles the problem by storing the minimum values needed for the sequence, ensuring that each ugly number is generated in order.

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

      ​@@gui-codesredundant how

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

      ​@@gui-codesi think majorly it's Greedy

  • @someshnayakrollno.-09sec-b27
    @someshnayakrollno.-09sec-b27 Місяць тому +1

    hii from 2024

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

    another solution(priority queue)
    class Solution {
    public:
    int nthUglyNumber(int n) {
    vectorarr = {2,3,5};
    long long count = 0;
    priority_queuepq;
    pq.push(1);
    pq.push(3);
    pq.push(5);
    setst;
    while(!pq.empty()){
    long long top = pq.top();
    pq.pop();
    if(st.find(top)!= st.end()){
    continue;
    }
    count++;
    st.insert(top);
    if(count == n){
    cout

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

    Sir javascript se bhi kra do please

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

      class Solution {
      constructor() {
      this.mp = new Map();
      }
      isUgly(n) {
      if (n 0) {
      if (this.isUgly(num)) {
      n--;
      }
      num++;
      }
      return num - 1;
      }
      }
      const solution = new Solution();
      console.log(solution.nthUglyNumber(10)); // Example usage with n = 10

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

      Bottom Up :
      class Solution {
      nthUglyNumber(n) {
      const t = new Array(n + 1);
      // t[i] = ith Ugly number;
      // we will return t[n] = nth ugly number
      t[1] = 1; // 1st Ugly number
      let i2, i3, i5;
      // i2th, i3rd, and i5th Ugly numbers initially point to 1, i.e., the first ugly number
      i2 = i3 = i5 = 1;
      for (let i = 2; i

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

    java code
    class Solution {
    public int nthUglyNumber(int n) {
    int[] arr=new int[n+1];
    int i2;
    int i3;
    int i5;
    i2=i3=i5=1;
    arr[1]=1;
    for(int i=2;i