Koko Eating Bananas | Leetcode 875 Solution | Searching and Sorting

Sdílet
Vložit
  • čas přidán 27. 05. 2021
  • Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
    NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. Question Statement:
    1. Koko loves to eat bananas. There are n piles of bananas, the ith pile has piles[i] bananas. The guards have gone and will come back in h hours.
    2. Koko can decide her bananas-per-hour eating speed of k. Each hour, she chooses some pile of bananas and eats k bananas from that pile. If the pile has less than k bananas, she eats all of them instead and will not eat any more bananas during this hour.
    3. Koko likes to eat slowly but still wants to finish eating all the bananas before the guards return.
    4. Return the minimum integer k such that she can eat all the bananas within h hours.
    Topic: #BinarySearch #leetcode875 #SearchingAndSorting
    Used #DataStructure: #Array
    #TimeComplexity: O(n*log(M)) , n is array size and M is maximum size of a pile.
    #SpaceComplexity: O(1)
    For detailed information and other exercises, VISIT: www.pepcoding.com
    Have a look at our result: www.pepcoding.com/placements​
    Follow us on our FB page: / pepcoding​
    Follow us on Instagram: / pepcoding​
    Follow us on LinkedIn: / pepcoding-education
    ----------------------------------------------------------------
    #BinarySearch #geeksforgeeks #SearchingAndSorting #leetcode875
    For a better experience and more exercises, VISIT: www.pepcoding.com/resources/o...
    Have a look at our result: www.pepcoding.com/placements
    Follow us on our CZcams page: / pepcoding
    Follow us on our FB page: / pepcoding
    Follow us on Instagram: / pepcoding
    Follow us on LinkedIn: / pepcoding-education
    Follow us on Pinterest: / _created
    Follow us on Twitter: home
    .
    .
    .
    Happy Programming !!! Pep it up 😍🤩
    .
    .
    .
    #pepcoding #code #coder #codinglife #programming #coding #java #freeresources #datastrucutres #pepcode #competitive #competitiveprogramming #softwareengineer #engineering #engineer

Komentáře • 72

  • @learnersparadise7492
    @learnersparadise7492 Před rokem +11

    This girl is a gem. She has gone deep into the problem, unlike many others who seems to have crammed solution and then make videos without understanding concepts.
    Hats off to her.

  • @pooja5213
    @pooja5213 Před 3 lety +20

    This is pure gold content. Thanks for explaining so well.

  • @VikashYadav-xz6dk
    @VikashYadav-xz6dk Před rokem +2

    brilliant explanation.

  • @NatureLover-oq6uc
    @NatureLover-oq6uc Před rokem +1

    Mam literally no one can explain in such an easy and elegant way....HATS OFF

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

    Best Explanation compared to other videos of similiar question on youtube. Great.

  • @rosonerri-faithful
    @rosonerri-faithful Před rokem +2

    Manisha Mam ka explanation is pure gold. Never I've walked out from her explanation videos feeling confused. Aap gem ho Mam!🙌🫡

  • @neerajyadav2349
    @neerajyadav2349 Před rokem +1

    Ma'am your explanation is too good

  • @sagar5430
    @sagar5430 Před 2 lety +2

    Mind blowing question

  • @yashkaushik8691
    @yashkaushik8691 Před 3 lety +8

    VERY GOOD EXPLANATION, GLAP TO HAVE TEACHERS LIKE U , THANKU SOO MUCH

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

      I am glad you liked it. I also hope that you are watching till end and trying to understand the what, how and especially why of the problem.
      If you like our efforts, we request a review
      g.page/Pepcoding/review?rc
      You can subscribe to our channel here
      czcams.com/users/Pepcodingabout?view_as=subscriber

  • @anujgupta6782
    @anujgupta6782 Před rokem +1

    Best explanation

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

    Thank You. Great Explanation!

  • @aindrilasaha1592
    @aindrilasaha1592 Před 3 lety

    Simply superb explanation, thanks!!

  • @nandinijaiswal725
    @nandinijaiswal725 Před rokem +1

    love u ma'am .You are the best.

  • @swatiksingh13
    @swatiksingh13 Před 6 měsíci

    Best Explanation

  • @kannupriyarana4971
    @kannupriyarana4971 Před 3 lety +2

    hats off to the way you teach . Thankyou :)

  • @PrinceKumar-el7ob
    @PrinceKumar-el7ob Před 2 lety +1

    great explanation loved it

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

    what an explanation 👏👏👏 best video explanation for this question. Thank you !

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Glad it was helpful!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @udaypratapsingh8923
    @udaypratapsingh8923 Před rokem +1

    brilliant explanation ::

  • @madetolaugh3476
    @madetolaugh3476 Před 2 lety +2

    Your explaination is brilliant. Best tutorial on the internet

    • @Pepcoding
      @Pepcoding  Před 2 lety

      For more of her content do check nados.pepcoding.com

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

    Very good

  • @saurabhtripathi378
    @saurabhtripathi378 Před rokem +2

    I request to pep coding to upload a video in which Mam tell us little bit about herself and her coding journey
    Please

  • @user-le3pr5mr1j
    @user-le3pr5mr1j Před rokem +1

    Thanks a lot mam, for most amazing explanation with deep insight. Mam is there any calculation possible such that we can calculate min_speed val,? as it would be atleast 1 & atmost max in piles.

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

    Thanks Mam :-)

  • @19_meghavatichaudhari92
    @19_meghavatichaudhari92 Před 2 lety +1

    amazing explanation ever...the way u explain is really superb.

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

      Glad you liked it!
      For better experience, visit nados.pepcoding.com, where you will get well curated content and career opportunities.

  • @ridimamittal4064
    @ridimamittal4064 Před 3 lety

    thank you :)

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Keep learning, Keep growing and keep loving Pepcoding!😊

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

    wow

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

    great explanation

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Glad it was helpful! Keep learning, Keep growing and keep loving Pepcoding!😊

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

    thanx di for this wonderful solution

    • @Pepcoding
      @Pepcoding  Před 2 lety

      Keep learning.
      For better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @niharika3608
    @niharika3608 Před 2 lety +2

    Mam, you are the best teacher :)

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

      Thankyou!
      Keep learning.
      And for better experience, visit nados.io, where you will get well curated content and career opportunities.

  • @user-ix6lx1rd6k
    @user-ix6lx1rd6k Před 6 měsíci

    i do the same but is give me 5 but ans is 4 for that test case Input: piles = [3,6,7,11], h = 18
    Output: 2 and my solution is
    class Solution {
    private static boolean isPossibleToEat(int[] arr, int speed, int h) {
    int time = 0;
    for (int i = 0; i < arr.length; i++) {
    time += (int) Math.ceil(arr[i] * 1.0 / speed);
    }
    return time

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

    dude, I'm solving this question for 1 hour and just saw the tag easy on your platform seriously? this question is just similar as allocation of pages in students from gfg which is hard level..

  • @LegitGamer2345
    @LegitGamer2345 Před 3 lety +2

    great explanation , production level code !

    • @Pepcoding
      @Pepcoding  Před 3 lety

      Glad it helped! and If you like our efforts, please upvote the comments written by the students about Pepcoding here (www.quora.com/What-are-the-good-websites-to-learn-data-structures-and-algorithms )

  • @PriyanshuKumar-hr9nv
    @PriyanshuKumar-hr9nv Před rokem

    class Solution {
    public int minEatingSpeed(int[] piles, int h) {
    int max = 0;
    for(int val : piles){
    max = Math.max(val, max);
    }

    if(h == piles.length){
    return max;
    }

    int lo = 1;
    int hi = max;
    int ans = 0;

    while(lo total hours

    for(int bananas : piles){
    th += Math.ceil((bananas * 1.0) / speed);
    }

    return th

  • @travellercoder7298
    @travellercoder7298 Před 2 lety

    The code is good but has an exception of zero division error so consider that also.. But overall it passed most of the cases

    • @Pepcoding
      @Pepcoding  Před 2 lety

      for better insight you can visit nados.io

  • @sharanpreetchadha5281
    @sharanpreetchadha5281 Před 2 lety

    Thanks for the video . 1 doubt tha min speed start mei 0 assume ki hai hum uss speed ko given array k min value kyu ni rkh skte?

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

      [2,2,2] and hours=10.. if we put low = min(of array) then ans would be 2 but actually we can even eat banana at speed of 1 banana per hour

    • @yuvraj3728
      @yuvraj3728 Před rokem

      @@mudrad1930 👍

  • @samyakjain1281
    @samyakjain1281 Před 2 lety

    description me iski complexity nlogm di ha where m is maximum size of pile nlogn nhi honi chahiye ????

  • @sunnykakrani7830
    @sunnykakrani7830 Před 3 lety

    madam ji is question ne hamari watt laga di 2 ghanta le lia hamra lekin lower bound ko 1 se initialize karne se hi pass hua ye leetcode par !!!

  • @tirthjshah7779
    @tirthjshah7779 Před 3 lety

    What will be the complexity?

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

    ma'am leetcode cases r not being passed using ur code.. pls check once over thr

  • @vikashsharma5844
    @vikashsharma5844 Před rokem +1

    Pep coding is not focusing to solve the questions....they will be focusing to clear the concept and theory.....Inke jaisa CZcams par koi nahi......kuchh do chaar ko chhodkar...

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

    thoda lenghty kar diya code , yeh aur easily explainable hai aur kam lines me bhi ho jayega

  • @neerajpandey8159
    @neerajpandey8159 Před 3 lety

    mam aggresive cow bhi kara do

  • @rajeev2127
    @rajeev2127 Před 3 lety

    Mam I think "lo" ko agar piles array ke minimum pe rakhege toh code thoda aur optimize ho skta h.. lo ko 0 se start krne ki zarurat nhi h shayad..

    • @_ADITIKAJALE
      @_ADITIKAJALE Před 3 lety

      it will fail for test case
      [6] , h = 6

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

    ONE TEST CASE FAILED
    Input:
    [805306368,805306368,805306368]
    1000000000
    Output:
    1
    Expected:
    3

    • @agamarora7906
      @agamarora7906 Před 3 měsíci

      Replace your Math.ceil statement to this and this test case would pass
      m += Math.ceil((double)piles[i] / (double)mid);