Leetcode 1648 Sell Diminishing Valued Colored Balls

Sdílet
Vložit
  • čas přidán 8. 09. 2024

Komentáře • 34

  • @kishores5121
    @kishores5121 Před 3 lety +7

    Superb explanation!
    One point I'd like to add here is that the reason why the heap-based solution doesn't work is that if you look at the constraints,
    the number can range up to 10^9, whereas the inventory length can range up to 10^5, that's why the sorting + the greedy approach is the efficient approach here!

  • @harshitsaluja3493
    @harshitsaluja3493 Před 2 lety +4

    The way you started was so good and after that when coding part started don't know what you did.

  • @vrushalijadhav2062
    @vrushalijadhav2062 Před 2 lety +1

    I tried coding the soultion out just from the explation, without using the formulas, and it timed out. Who can come up with these formulas during a 45 mins interview unless they have memorised it :D

  • @nato_allies8-ws1nj
    @nato_allies8-ws1nj Před 6 měsíci

    12:26 onwards LOST :(

  • @lingasodanapalli615
    @lingasodanapalli615 Před rokem

    You could have used some meaningful names. Also you didn't explain in the code that how is the case of having multiple rods of maximum height is being handled. It is not intuitive from the code.

  • @arijitdey8419
    @arijitdey8419 Před 2 lety

    great explanation...keep up the good work and thanks a lot

  • @vipin21
    @vipin21 Před 3 lety +4

    Such a nice explanation however the coding part was really bad I just got lost x, l, r etc. I wish you would have used good variable names and provide some details while writing the formula.

    • @mohammadfraz
      @mohammadfraz  Před 3 lety

      Will keep that in mind. Thanks for the useful suggestions 😊

  • @akshatgupta107
    @akshatgupta107 Před 2 lety +1

    As a Google Developer, shuldn't you be giving some better variable names rather than random x,y,o?? Dont get me wrong- your explanation is great, but its frustrating to read and understand your code when your variables names are so horrible! Please use better variable names!

  • @akhilkhubchandani2632
    @akhilkhubchandani2632 Před 3 lety +1

    Very nice explanation . Keep making more videos 💯

  • @ankita1464
    @ankita1464 Před 3 lety +3

    i also came up with the heap based solution but i am getting TLE for the test case:- inventory = [1000000000], orders = 1000000000. Can you pls tell how to handle this one

  • @shahperzia1121
    @shahperzia1121 Před 3 lety +1

    please attach your code also.

  • @FirefoxGuy18
    @FirefoxGuy18 Před 3 lety

    Hey thank you so much for explaining this question. Appreciate the effort :)

  • @TarunSharma-iv7iv
    @TarunSharma-iv7iv Před 3 lety

    Thank you for making this video!!

  • @siddhartha166
    @siddhartha166 Před 3 lety

    Keep up the hard work

  • @ankita1464
    @ankita1464 Před 3 lety

    What if we have same number of balls in the inventory I mean when all the elements in vector are same?

    • @mohammadfraz
      @mohammadfraz  Před 3 lety +1

      Ankita just watch the video carefully , you will your answers.
      We are handling this condition as well.

  • @carry4398
    @carry4398 Před 3 lety +4

    please explain by writing each case separately instead of writing short code (which seems hard to understand).

  • @bismeetsingh352
    @bismeetsingh352 Před 3 lety

    What is l and r in the last approach?

    • @mohammadfraz
      @mohammadfraz  Před 3 lety

      R is the right limit. And l is left limit.
      So basically you have to find the sum of all number from left(l)+1 to , right(r)

    • @ankita1464
      @ankita1464 Před 3 lety

      Hey can you explain how u came up with the formula ret+= l*(X%n-i)

    • @bismeetsingh352
      @bismeetsingh352 Před 3 lety +1

      @@mohammadfraz Can you redo the video with a easy to understand explanation?

    • @kishores5121
      @kishores5121 Před 3 lety

      @@bismeetsingh352 The video is good enough, Watch it again.

    • @bismeetsingh352
      @bismeetsingh352 Před 3 lety

      @@kishores5121 Sorry, I still dont get it.

  • @alecchampaign262
    @alecchampaign262 Před 2 lety +1

    Your explanations would go much further if you used more understandable variable names (even at the cost of writing longer code). Remember, code is meant to be read by humans too!

  • @harveyspector1463
    @harveyspector1463 Před 3 lety

    Which laptop are you using? Are you using a pen

    • @mohammadfraz
      @mohammadfraz  Před 3 lety

      Asus vivobook s14 . Yes I am using digital pen