Leetcode 1760. Minimum Limit of Balls in a Bag

Поділитися
Вставка

КОМЕНТАРІ • 41

  • @rachavinay1731
    @rachavinay1731 3 роки тому +11

    instead of using INT_MAX ,can we use maximum element in nums array?

    • @mohammadfraz
      @mohammadfraz  3 роки тому +3

      Definitely you can

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

      Yes, I use Math.max(...nums) in JS and it's working.

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

      @@jimmyliao6429 great

  • @thatipelli1
    @thatipelli1 3 роки тому +1

    Thanks for making it so simple!!

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

    Awesome Mohammad, thanks a lot! by the way what is the name of the editor you're using for explanation?

  • @sadmanabedin1203
    @sadmanabedin1203 3 роки тому +1

    if nums[i]%mid==0, then people may assume that it'll take (nums[i]//mid) operations to reduce it in a way that maximum number becomes equal to mid. But that's wrong, it'll take ((nums[i]-1)//mid) operations.
    Anyways, thanks for the fantastic solution

  • @tomharper1264
    @tomharper1264 3 роки тому +3

    Thanks for sharing this, super helpful! Keep it up, this is awesome! :D

  • @paragroy5359
    @paragroy5359 3 роки тому

    Nice explanation sir....your videos are really helpful....keep making more videos

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

    Nice explanation, Binary Search is amazing to me in this question.

    • @jimmyliao6429
      @jimmyliao6429 3 роки тому +1

      And also in last weekly contest question
      Closest Subsequence Sum
      leetcode.com/problems/closest-subsequence-sum/

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      Thanks 😊

  • @ramchandrayadav8378
    @ramchandrayadav8378 3 роки тому

    Thanks a lot. Very helpful and nice explanation💥

  • @doug1727
    @doug1727 3 роки тому

    very nice explanation! the binary search is a nice touch. I could not come up with a solution during the contest.

  • @yousufhussain9530
    @yousufhussain9530 3 роки тому

    Amazing! Liked and subbed!

  • @niksgupta36
    @niksgupta36 3 роки тому

    What will be the time complexity?

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

    Fraz in the timeframe 9:00 at first you divided the value by 2 and reduced with minus (-1) but when you dividing it with 3 why you didn't subtracted with -1?

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

      is that due to that fact that m(8) is not a factor of the value 4 and 8. If its a factor we need to reduce the result with -1? am i right

  • @lifehacks9450
    @lifehacks9450 3 роки тому

    nice pls upload the solution of zuma game on leetcode

  • @vertika287
    @vertika287 3 роки тому

    Thanks a lot!!! :D

  • @learner_1228
    @learner_1228 3 роки тому

    Brother, I have a doubt, sometimes we are returning L or R in binary search or in other cases storing our ans is a variable & returning it. How to decide ?

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      In no example I have return l or r.
      I always store in ans

    • @learner_1228
      @learner_1228 3 роки тому

      @@mohammadfraz int minimumSize(vector& A, int k) {
      int left = 1, right = 1e9;
      while (left < right) {
      int mid = (left + right) / 2, count = 0;
      for (int a : A)
      count += (a - 1) / mid;
      if (count > k)
      left = mid + 1;
      else
      right = mid;
      }
      return left;
      see lee's code- he is returning left and mid=(left+right)/2 instead of (right+(right-left)/2) ,later one gives error/wrong ans is some problems
      even his looping condition is different.
      I have seen this many times but didn't understand the variations.
      could you please explain?

    • @mohammadfraz
      @mohammadfraz  3 роки тому +1

      @@learner_1228 that is why I was trying to keep it simple in my series.
      I never return l or r.
      Don't see so many codes if it's confusing you. Stick to one.

  • @bismeetsingh352
    @bismeetsingh352 3 роки тому +1

    Can you explain the mathematics part? I dont get it.

    • @mohammadfraz
      @mohammadfraz  3 роки тому +3

      Yes ,
      So let say you have 7 and you want to make parts of 7 such that no part is bigger thn 2
      Thn 7=(2,5)=(2,2,3)=(2,2,2,1)
      So you took 3 moves
      That is equal to 7/2
      And let's say you have 8
      Thn 8=(2,2,2,2) you took 8/2 -1 moves
      So number of moves you take is qual to nums[i]/x(min allowed number) -1 if nums[I] is divisible by x
      And it's nums[i]/x if nums[I] is not divisible by x

  • @shivam_dhyani
    @shivam_dhyani 3 роки тому

    Please increase the text size in leetcode also zoon in the screen while recording the solution!!

    • @mohammadfraz
      @mohammadfraz  3 роки тому +1

      I always forget to do it , will keep in mind

    • @shivam_dhyani
      @shivam_dhyani 3 роки тому

      @@mohammadfraz Thank you for taking it into consideration 🙏

  • @dheerjain2884
    @dheerjain2884 3 роки тому

    Ngl, Q4 was easier and straight forward kaafi this time

    • @dheerjain2884
      @dheerjain2884 3 роки тому

      Q3 strike hi nhi hua kuch during contest

    • @mohammadfraz
      @mohammadfraz  3 роки тому

      Okay , is it clear from the video

    • @dheerjain2884
      @dheerjain2884 3 роки тому

      @@mohammadfraz Yes. Definitely🤘🏻

  • @Prashantkumar-pn6qq
    @Prashantkumar-pn6qq 2 роки тому

    At 6:13, how did you use 3 operations? I think its still 2 operations only : [7, 17] -> [6, 1 , 11, 6] -> [6, 1, 6, 5, 6]

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

      Nope. First operation is when we divide 7 into 6 and 1. Second operation is when we divide 17 into 11 and six. And finally third operation is when we further divide 11 in five and so in total there are three operations

    • @Prashantkumar-pn6qq
      @Prashantkumar-pn6qq 2 роки тому

      @@panavkumar9009 thanks