Minimum Limit of Balls in a Bag | Leetcode 1760

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

КОМЕНТАРІ • 38

  • @manishbolbanda4614
    @manishbolbanda4614 8 днів тому +4

    Techdose is my goto channel for any DSA Problem. the way you explain the approach is super good.
    i was part of Techdose batch in Oct-2022 and its worth the money - it really helped me crack Morgan's interview like a cup cake.
    Thank you Surya for your contribution.

  • @VISHALMISHRA-ff2ih
    @VISHALMISHRA-ff2ih 8 днів тому +4

    to be honest first I thought this is a Priority queue Problem. Hats off to your explanation.

  • @iffyaiyan8942
    @iffyaiyan8942 7 днів тому

    hey thanks for the explanation, there is some fix in the Python code, as some test cases failed
    class Solution:
    def canAssign(self, nums, max_val, operations):
    count = 0
    for ele in nums:
    if ele > max_val:
    # Calculate the number of operations needed to split the bag
    count += (ele - 1) // max_val # Equivalent to ceil(ele / max_val) - 1
    return count

    • @techdose4u
      @techdose4u  7 днів тому +1

      python too! there was some bug in java :o thanks

  • @dhruthiaddagatla2959
    @dhruthiaddagatla2959 8 днів тому

    Well explained !
    But definitely, from our side we need to have the will and patience to learn and understand!

  • @JuicyM0N
    @JuicyM0N 8 днів тому

    Great explanation !! Thanks

  • @vinodpaluvuri54
    @vinodpaluvuri54 8 днів тому +1

    Nice explanation

  • @SumanDas-fx5vu
    @SumanDas-fx5vu 8 днів тому

    God level explanation 🙏🙏🙏

  • @srikantkumar9860
    @srikantkumar9860 8 днів тому

    great explaination thank u

  • @Bruce_Wayne1720
    @Bruce_Wayne1720 8 днів тому

    you are the greatest

    • @techdose4u
      @techdose4u  8 днів тому

      Thanks for your appreciation:)

  • @sailendrachettri8521
    @sailendrachettri8521 8 днів тому

    Thank you sir :)

  • @lohithaadapala6989
    @lohithaadapala6989 8 днів тому

    Thankyou :)

  • @IT__RAJVEERSINGH
    @IT__RAJVEERSINGH 8 днів тому

    Thank you

  • @vooratharunkumar4704
    @vooratharunkumar4704 8 днів тому

    why can't search space can be start=minimum_number in array and end=maximum_number in array?

    • @lohithaadapala6989
      @lohithaadapala6989 8 днів тому

      Take [2,3] and maxOperations = 5 and trace out. The answer is 1 but if you take the range as min then the answer would be 2 but the actual answer would be 1.

  • @vibhoragarwal2935
    @vibhoragarwal2935 8 днів тому

    what was your intuition for binary search? couldn't think of it

    • @techdose4u
      @techdose4u  8 днів тому +3

      It is a standard binary search assignment/asnwer range search problem. No intuition required.
      Practice problems: Aggressive cow, Painters partition problem, book allocation problem, Capacity To Ship Packages Within D Days
      :)

    • @rechinraj111
      @rechinraj111 8 днів тому +1

      Simple hai : jahan bhi MAX of MIN ya phir MIN of MAX dekho.
      Think of binary search.

  • @dhruthiaddagatla2959
    @dhruthiaddagatla2959 8 днів тому

    But my doubt is while solving this qsn for the first, how do we come to this solution !

    • @techdose4u
      @techdose4u  8 днів тому

      You should have solved similar questions or else this will add to your learning :)

  • @top10z38
    @top10z38 8 днів тому

    operations += (num - 1) // penalty
    i still dont get it .
    consider num = 8 , penalty = 4
    we are checking
    = (8-1) // 4
    = 1 -> this gives value as 1
    but we can also divide 8 as 5,3 - 6,2 - 7,1 right . why are we only consider less than value

    • @techdose4u
      @techdose4u  8 днів тому

      yes because 1 operation is required to make 2 bags each of 4 size :)

    • @top10z38
      @top10z38 8 днів тому

      @@techdose4u so its like no matter the operations should be overflow the give size right ?

    • @techdose4u
      @techdose4u  8 днів тому +1

      @top10z38 Thats why we are checking if total operations are > max operations :)

  • @YouCodeRK
    @YouCodeRK 7 днів тому

    How I can think like this for a tricky problem like this. I know Your answer may be 'Practice'. But it does not always work.

    • @techdose4u
      @techdose4u  7 днів тому

      It will always work provided enough problems experience. I wouldnt suggest to worry so much if you are preparing for interviews though :)