43 Egg Dropping Problem Recursive

  Рет қаралды 168,521

Aditya Verma

Aditya Verma

Күн бұрын

Пікірлер: 282
@kirtipurohit1237
@kirtipurohit1237 2 жыл бұрын
There are very rare people who teach geniune content on YT without any fake drama or promotion. Wish we have more people like you
@prabhatpandey1638
@prabhatpandey1638 4 жыл бұрын
It is very important to understand why we are sending (f-k) in case of egg didn't break and again using a for loop where k is initiated from 1 again. the reason is we are checking for a range where we are min number of possibly attempt where egg didn't break. Let's say in simple terms there are 10 floor. Egg didn't break from 7th floor. So now only 10-7 = 3 floor needs to be checked. But to check the next 3 floor we need to use a k loop again. Here k=1 will represent 8th floor. Here k=2 will represent 9th floor. Here k=3 will represent 10th floor. So to answer the initial question , You need to check the min number of attempts in next 3 floors and that is why you are sending (f-k) and k range is (1,f-k) PS. I was not able to understand for 2 days why we are looping from K=1 again. Putting this explanation out incase someone gets stuck in the same point again.
@nileshdand2431
@nileshdand2431 4 жыл бұрын
Bro can u explain why are we using max, i.e how are we understanding the worst the case in this
@monildand4366
@monildand4366 4 жыл бұрын
can you explain use of max.
@kumarsaurabhraj6917
@kumarsaurabhraj6917 4 жыл бұрын
@@nileshdand2431 Will try to explain this, we have to find the minimum number of attempt to find the critical floor, we don't know which floor would be the most optimal floor to make the first attempt hence we are trying out all the floors through the loop, also we do not know if dropping from a certain floor will cause the egg to break or not so we are testing for both cases one in which we assume that the egg would break and in the other we assume that it won't, recursive calls with left over eggs and floors in both cases give us the number of attempts required. But since the question asks us to assume the worst case we take the possibility as a fact which requires greater number of attempts to find the critical floor. In simpler terms, suppose if we are testing for the 3rd floor then we check the number of attempts to find the critical floor for both cases if the egg would break from the 3rd floor and if the egg wont break from the 3rd floor, if it requires greater number of attempts to find the critical floor if the egg would break if dropped form the 3rd floor then we would assume that upon dropping from the 3rd floor the egg would actually break because we want the worst case here. Then we take the minimum of number of attempts required for finding the critical floor in worst case of all of the floors in our range and that is the answer. This was a little long but I hope this clears things. Thanks
@silverbullet_6
@silverbullet_6 4 жыл бұрын
thanks bro........saved my time!
@nikhil08514
@nikhil08514 3 жыл бұрын
Exactly what i was looking for.. Thanks :)
@lakshaychawla78
@lakshaychawla78 2 жыл бұрын
Adi bhai, mujhe 3-4 months ho gye jb maine first time ye DP ki series start ki thi. Uske baad i went through all of different topic series you taught. Even today sometimes i revise such concepts and questions before some interview or so. Mai dil se shukriya krna chaunga for such great concept building exercises ❤️❤️ and even urge you to make such videos for other concepts as well like backtracking, greedy, graphs etc. People need you👌🏻
@vedantnaikwadi5394
@vedantnaikwadi5394 2 ай бұрын
bro app kis company me ho abb?
@kumarsaurabhraj6917
@kumarsaurabhraj6917 4 жыл бұрын
Some hints if someone is having a hard time understanding this We are given with the number of eggs and the number of floors in the building We have to find the minimum number of attempts to find the critical floor with the given number of eggs (we can have leftover eggs) If we have only one egg then there is only strategy to keep dropping eggs starting from the bottom till we get to a floor where the egg breaks then we found the critical floor which will be the floor below it We do not have any facts on where from dropping from a particular floor wheather the egg breaks or not, for every floor the egg may or may not break We have to find the niminum number of attemps it would take to find the threshold floor in the worst case What would be best case? We select any floor and drop the egg from it and it does not break and we drop the egg from the floor above it and it does break, then our previous floor will be the critical floor. So in the best case it would take us two attempts and 1 egg to find the critical floor. Why just testing for in the middle and halving the floor is not necerrily a good solution? Becuase if you have only one egg left then you would have had to make as many attempts as there are floors to find the critical floor. What we are doing here? Our function returns the minimum number of attempts required to find the critical floor with E eggs and F floor (given in arguments), we dont what would the most optiomal floor to make the first attempt from so we are making attempt from every floor, we also dont know if by dropping from a floor wheather the egg would break or not so we test for both the cases, we recursively call the function for the left over floor and eggs, since we assume the worst possible case here and we do not know if from dropping from a floor wheather the egg will break or not, we check for which situation it would take greater number of attempts to find the critical floor and take that one. Also since we want the minimum number of attempts to find the critical floor in the worst possible case we take the minimum of the number of attempts required in the worst possible case when the first attempt is made from that fllor and return that as our answer. Under standing base cases, When there is only one egg then we would have to make as many attempts are there are floors in the worst case to find the critical floor. When there is only one floor then we would have to make only one attempt if the egg does not break then its the critical floor and if it does then ground floor is the critical floor, so the number of attempts in this case also would be as many as there are floors. When we have no eggs then its not possible to find the critical floor. Wehn there are no floors i.e. 0 floors then the group floor will be the critical floor so the answer would be equal to 0 i.e. number of floors.
@vasutiwari4187
@vasutiwari4187 3 жыл бұрын
where are some hints ??
@gamingKlips99
@gamingKlips99 3 жыл бұрын
good
@nitinkumar5974
@nitinkumar5974 3 жыл бұрын
Good ,Well explained 👍
@siddharthsharma3914
@siddharthsharma3914 3 жыл бұрын
Thanks a ton for explaining.
@RitikSingh-bt3gp
@RitikSingh-bt3gp 3 жыл бұрын
english subtitles to the video..xd
@visase2036
@visase2036 2 жыл бұрын
For those who did not get the max and min usage here : Consider there are 10 floors in total and we got some x eggs to test . Lets say we are at 8th floor now(Problem would start from the 1st floor but consider that we are at 8th) . Here we have two options . 1. Egg breaks (we are left with x-1 eggs and 7 floors (8th floor is not the critical one so go down by 1 floor) 2. Egg does'nt break ( we are left with x eggs and 2 floors(9,10 to test) as 8th floor did not break , its waste of time to go down and check other floors as the problem states if the egg doesnt break at one floor it doesnt break on the floors below to it as well )) Now here comes the critical point to note , floors to test now are 1. 1-7 so total of 7 floors(egg broke) 2. 9-10 so total of 2 floors (egg did not break) Whom do you think will give the us the answer Max(attempts (7 floors), (2 floors))) , obviously 7 will yeild more floors to test (Keep in mind , you have to cover all the floors so go by max). So that is the reason why we use max(floorsRemainingEggBrokenCase, floorsRemainingEggunbrokenCase) And finally here comes the min part : Now we tested this by dropping the egg at 8th floor , similarly 3rd floor will yeild us an answer , similarly 5th floor will yeild a diff ans and so on ... till n floors Tats y we return the min(egg drop attempts on all the floors)!
@alexwhitewood6480
@alexwhitewood6480 Жыл бұрын
Well explained
@pranjalck
@pranjalck Жыл бұрын
Thanks bro it helped
@kashishkatiyar7923
@kashishkatiyar7923 Жыл бұрын
thannx bro
@manasvinsharma1740
@manasvinsharma1740 2 жыл бұрын
At first, it looks like a problem which can be solved by Binary Search
@kartikwar8022
@kartikwar8022 2 жыл бұрын
It can be solved. But he has given a solution without it. You can optimize further by using binary search
@g8dboyplays790
@g8dboyplays790 2 жыл бұрын
You can, but that will require infinite eggs to reach the solution. There are limited no. of eggs, so we prefer DP here.
@KiyotakaAyanokoji1
@KiyotakaAyanokoji1 Жыл бұрын
@@g8dboyplays790 floors limited hai toh infinite egg kaise lag sakte binary serch me
@KiyotakaAyanokoji1
@KiyotakaAyanokoji1 Жыл бұрын
ha at first , it seems ki we were given the value of threshold floor. then we could apply binary serch
@AnshiPatel_official
@AnshiPatel_official Жыл бұрын
Exactly
@0anant0
@0anant0 4 жыл бұрын
42 of 50 (84%) done! The concept is explained very nicely.
@shashishekhar1729
@shashishekhar1729 4 жыл бұрын
KAUN HAI YE LOG , KAHA SE AATE HAI YE LOG!
@aishwarya1895
@aishwarya1895 3 жыл бұрын
Man your consistency ✌️
@starc701
@starc701 4 жыл бұрын
max is used since ,we have to find guaranteed moves to find the breaking floor, to find gurantee we take worst cases. Nice vdo
@lakshsadhwani855
@lakshsadhwani855 3 жыл бұрын
man you never can explain bad🙈 respect bro for the content you give us , keep growing❤️
@ytg6663
@ytg6663 2 жыл бұрын
Laksh
@manishkumargupta8677
@manishkumargupta8677 2 жыл бұрын
Angrez wali English nahi pel diye bhai idhar tum? Hindi me video dekh karke
@sleepypanda7172
@sleepypanda7172 2 жыл бұрын
@@manishkumargupta8677 isse zyada simple english kya ho skti hai? sahi se toh bola hai vo. Angrez wala kya hota hai. Ek seedhi si line likhi hai
@Official-tk3nc
@Official-tk3nc 4 жыл бұрын
my 12 years old brother saw this video with me now he can solve egg drop problem conceptually:)
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Haha Really dude? 😂😂 I am hope your not forcing him to watch videos to turn him into a programmer at a young age 😂😅✌️
@adarshsharmanit356
@adarshsharmanit356 4 жыл бұрын
@@TheAdityaVerma Indian Errichto Ban jaayega ,aisa banda 12 saal se hi start kar dega toh , Bhad mein jaaye JEE , Google phod dega aise hi 😂😂
@rahulagarwal8059
@rahulagarwal8059 4 жыл бұрын
😂😂
@AnkitSingh-qz8ix
@AnkitSingh-qz8ix 3 жыл бұрын
chintu or wott
@kaal_bhairav_24
@kaal_bhairav_24 3 жыл бұрын
bhai wolf gupta se door rakhio apne chote bhai ko
@anshulgoel1940
@anshulgoel1940 Жыл бұрын
Some people call this as front partitioning and not MCM and I was always confused whats the damn difference. This video made it super clear. Just a small variant of the same thing.
@chhaviagarwal7514
@chhaviagarwal7514 3 жыл бұрын
Loved your way of teaching..Can you please upload videos for remaining topics like kadane's algo and Longest Increasing Subsequence🙏🙏
@bharatnihar
@bharatnihar 2 жыл бұрын
Bhai maja aagaya explaination dekh k.Baith gya dimag m Best tutorial for this question on KZbin.
@nitianthrive6099
@nitianthrive6099 Жыл бұрын
Dil se hats off for your explanation 🫡🫡
@gaunikasrivastava7851
@gaunikasrivastava7851 2 жыл бұрын
This problem is tougher than scramble string problem 😅😅
@MakeuPerfect
@MakeuPerfect 2 жыл бұрын
Because of Max
@rishabhgaurav
@rishabhgaurav 4 жыл бұрын
And Can you Please List Down the question at least of the topics which you couldn't upload. Like In the first video you mentioned... Fibonacci(7 questions) LIS(10 questions) Kadane's (6 questions) DP on grid(14) others(3) So that I can complete these topics as well. PS: You have a very good and curated playlist.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Do not have a list right now Sorry 😕, But will try to upload them as well.
@sauravdas7591
@sauravdas7591 4 жыл бұрын
leetcode.com/discuss/general-discussion/458695/dynamic-programming-patterns> try this, as it contains a no of separate patterns dp
@0anant0
@0anant0 4 жыл бұрын
@@sauravdas7591 Highly underrated comment. Should be pinned on the first or last video of this DP series.
@sachinsharma905
@sachinsharma905 3 жыл бұрын
@@sauravdas7591 Thanks man.
@ahishnar1568
@ahishnar1568 3 жыл бұрын
@@sauravdas7591 Thanks man
@CricketGalaxy07-18
@CricketGalaxy07-18 Жыл бұрын
me ye ek problem sikhane aaya tha or puri MCM pertan sikh li thanks sir 🤩🙌🙌
@lj2738
@lj2738 4 жыл бұрын
bhai may month aa gaya hain ,waiting for new series..& thanks :)
@bhargabnath5781
@bhargabnath5781 3 жыл бұрын
bhaiya, I'm sure that you you must be unwell atleast a little bit, I hear your voice and feel like this. How can I show you my respect for you? Thank you so so much bhaiya, like every videos, this too is simply lit. Kudos to your dedication, bhaiya!!! :) :) :)
@ahishnar1568
@ahishnar1568 3 жыл бұрын
If someone is not able to understand the problem itself then read below explanation. Here in this problem we have to find the minimum attempts required to find the threshold floor in worst case. For finding this on every step of recursion we have to find one floor or such a floor from which if we drop an egg then we would be required a minimum attempts overall to find threshold floor overall. And if we follow this concept which I just explained on every recursion step till vase case get hit then with magic of recursion we will automatically get most optimized approach in worst case. e.g. Let's say we have 5 floors as 5 4 3 2 1 Then in for loop we have to check one floor or such a floor from which if we drop an egg then we overall we would get minimum attempts. So in for loop first we will check for 5 then check for 4 then for 3, 2, 1 and at then end as we required minimum number of attempts so in for loop after finding for was floor that is after assuming each floor as the first floor to drop from, we will take or we will pick that floor from which if we drop an egg then we required minimum attempts. And so in for loop we use min function. Now the second thing is after dropping an egg 2 things can happen, either egg will break or not break. If egg breaks then we will go down to check and if egg does not break then we will go up to check. Now as we need minimum attempts in worst case, concentrate here I am saying in worst case we required minimum attempts and so as we are checking for worst case then egg breaking can be the worst case or egg not breaking can be the worst case. But we do not know which is the worst case and so we are cheking for both the cases. And so we have to take or use max function here so that we can catch the worst case. And that is why while calling egg break and not break recursion calls which are below the current floor and above the current floor respectively we have to use max function. So in short on every step of recursion out of all the floors we have to find one floor or such a floor from which if we drop an egg then we would required minimum attempts. I hope this helps :)
@AnushkaRai-mr8hh
@AnushkaRai-mr8hh 5 ай бұрын
Yess! Finally I got it! Thanks!
@yashmittal9040
@yashmittal9040 4 жыл бұрын
had to watch this video like to 4 to 5 times to properly understand what is the meaning of worstcase but finally understood
@chavanitinsaichowdary8088
@chavanitinsaichowdary8088 2 жыл бұрын
Can u explain
@himanshusoni1512
@himanshusoni1512 2 жыл бұрын
For 100% certainty, always consider the combination of your BEST and others' WORST Case.
@ShreyaSingh-vr9qi
@ShreyaSingh-vr9qi 4 жыл бұрын
Nice explaination !! I was confused a lot about why to choose worst case but now its cleared. Thanks for explaining.
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
I am glad it helped you. Share where ever you can it would help me :P
@aparnatiwari6442
@aparnatiwari6442 Ай бұрын
Thanks for the amazing explanation
@kumarsaurabhraj2538
@kumarsaurabhraj2538 4 жыл бұрын
I think there should be another base case, when e == 0 then return INT_MIN or -1 since its not possible to find the number of attempts to find the critical floor if we have no eggs so we would want such cases to be eliminated in out max() comparison.
@prakhargupta5720
@prakhargupta5720 3 жыл бұрын
for those who didn't understand why we use MAX :- assume that for 1 to f floor we put k somewhere in between of 1 and f and we find the answer then it would be the best case. But here we have to check each floor because we have to find the last floor where egg didnt break , not the floor where egg breaks. Hope u undrstand.
@harshdeepsingh6768
@harshdeepsingh6768 3 жыл бұрын
Bro I am struggling to understand this, can you please explain it with an example... like what would have happened if we took min instead of max there.
@OmkarGhanekar
@OmkarGhanekar 2 жыл бұрын
@@harshdeepsingh6768 That is because we don't know if, after choosing to have an attempt from floor k, our egg will break or not and subsequently we dont know which path we will have to take. So we account for whichever path takes us more attempts and then declare that if we choose to drop from k then we will DEFINITELY be able to solve it in 1 + max(recursive calls) attempts. so we calculate this collection of "can definitely solve it in N drops" for all Ks and then pick a K where this value is smallest
@pavankumar-cy6mg
@pavankumar-cy6mg 3 жыл бұрын
.It is not ruled out that the first-floor windows break eggs, nor is it ruled out that the 36th-floor do not cause an egg to break.
@iamnoob7593
@iamnoob7593 2 ай бұрын
Thanks very good explanation
@prakhartiwari8153
@prakhartiwari8153 4 жыл бұрын
bro eagerly waiting for other patterns like Fibonacci series etc,,,,, :(
@codebot1027
@codebot1027 3 жыл бұрын
Thank You Soo Much Aditya, You Explained It Very Well...
@gauravdixit2288
@gauravdixit2288 4 жыл бұрын
@Adi bhai can u please tell the time complexity of recursive version and also please discuss the n^logn approach
@saurabhthakur2718
@saurabhthakur2718 Жыл бұрын
very simple explanation, thank you !
@harshchiki7796
@harshchiki7796 4 ай бұрын
you built the building some many times - it felt like a civil engineering problem than the computer science problem some times.
@alexamish2020
@alexamish2020 4 жыл бұрын
I have a major doubt, We are calling solve(e, f). Doesnt it matter, what length of last K we have already checked ? Why the answer always depends on the number of floors and not the floor number. Please clear.
@akhilmanoj5512
@akhilmanoj5512 4 жыл бұрын
When the egg breaks from the k-th floor, we consider a subproblem with the height of the building as k. Similarly, when it doesn't break from the k-th floor, you can consider another subproblem with the ground being at the k-th floor level. Due to this fact, the floor number doesn't play a role in the solution.
@RanjeetSingh-st2vu
@RanjeetSingh-st2vu 4 жыл бұрын
Sir in this problem why we can't use binary search?
@ritishdhiman26
@ritishdhiman26 4 жыл бұрын
best lectures on dp , thanks :)
@shakshigupta1336
@shakshigupta1336 Жыл бұрын
Why can't we use binary search for e-1 eggs (halfing the floors each time) and then use the last egg one by one for remaining floors?
@badabeta6973
@badabeta6973 11 ай бұрын
I have the same doubt can anyone explain
@167shivamrai2
@167shivamrai2 3 жыл бұрын
@aditiya verma Really appreciate your efforts , that helps all of us. I think govt. should give job to teachers like him who are devoted and dedicated to their work . The govt should pay them salary double which are getting in MNCs , to teach the youth . This man skills and presentation work is so good , then those of NPTEL lecture teachers which are being arranged by govt for youth programming education. Man like him want to teach and understand the importance of basics taught to young programmers , but can't balance all time to do so because of their job roles. I wholeheartedly wish teachers like him should given importance by govt. as they are nourishing the youth with great programming skills . I don't have free time to write such a long comment, but this man deserves appreciations from all of us. If you like this, pls share this on linked in . With mentioning name of teachers like him who should be given vote of appreciations.
@amanchauhan7451
@amanchauhan7451 3 жыл бұрын
Do this Problem is practically possible? How we can determine that the minimum no of Steps for finding Threshold floor for Floors =100 and Eggs = 2 is 14 ???
@AryanGairola-th3qc
@AryanGairola-th3qc 3 ай бұрын
go to 50th floor drop it if it breaks strat from 1 because now you rae left with 1 only if it doesnot break from 50 th than go to 75 and repeat the process but as you said it breaks you will ned 15 steps first to got to 50 and then 1 byb one till 14
@csinfoplus3788
@csinfoplus3788 8 ай бұрын
Great explanation ...
@siddharthkeshri5649
@siddharthkeshri5649 3 жыл бұрын
I think a best approach of this problem can come from binary search it's just a hunch not checked till now
@Bdixit
@Bdixit 3 жыл бұрын
I was also thinking somewhat this in my mind.
@siddharthkeshri5649
@siddharthkeshri5649 3 жыл бұрын
@@Bdixit yes Bro a approch exists of Binary search and its the best one 😅
@oqant0424
@oqant0424 3 жыл бұрын
though took some time to understand .....but the explanation was awesome!
@dinakarmaurya8000
@dinakarmaurya8000 3 жыл бұрын
Is it possible to try using binary search technique? Try to fall from middle?
@abhishekbajaj109
@abhishekbajaj109 4 жыл бұрын
If you have a doubt that why we are taking max then let me explain you the question is using you to find minimum no of attempts to find the threshold in worst case. Focus on the word Worst case if we take min there we would not get the answer for the worst case for eg take 2 eggs and 2 floors 1) 1+max(sol(0,0),sol(1,1)) from this you can tell if egg breaks in first floor then its not the worst case here the worst case is 2nd floor so we go to second floor to test it so from there you will see why we used max and later to find min attempts we use min . i hope this helps.
@maximus6448
@maximus6448 3 жыл бұрын
N^ 2 solution : def superEggDrop(self, egg: int, floor: int) -> int: dp = [[0]*(egg+1) for i in range(floor+1)] for i in range(1 , floor+1): for j in range(1 , egg + 1): # two case arises starting from ground floor # when we are moving from bottom to top either # egg breaks or not if egg breaks we decrease egg count # else not and 1 is increasing the number of attempt after # every floor when egg breaks. # dp[i-1][j-1] when egg breaks # dp[i-1][j] when egg does not break. dp[i][j] = 1 + dp[i-1][j] + dp[i-1][j-1] if dp[i][j] >= floor: return i
@mickyman753
@mickyman753 3 жыл бұрын
the critical floor can be any floor and it is not any specific floor, worst case main kisi bhi random floor se start krne pr kitne minimum attempt lgenge , aise sab starts se no. of attempts ka minimum nikalna hai
@ankoor
@ankoor 4 жыл бұрын
Python: Recursive def Solve(eggs, floors): if floors == 0 or floors == 1: return floors if eggs == 1: return floors count = float('inf') for i in range(1, floors+1): temp = 1 + max(Solve(eggs, floors-i), Solve(eggs-1, i-1)) count = min(count, temp) return count eggs = 3 floors = 5 attempts = Solve(eggs, floors) print('# of attempts: ', attempts)
@roliagrawal3124
@roliagrawal3124 3 жыл бұрын
@Aditya Verma I am not getting why we are taking worst case?
@navjyotbhele8307
@navjyotbhele8307 3 жыл бұрын
because in best case we only need 2 attempts. That is we choose a random floor luckily and the egg is not broken from that floor(1st attempt) and from the floor on top of it, egg breaks(2nd attempt) that is the curr floor is critical floor. Hence we require 2 attempts only. hence we are asked to to take worst case
@MrRavi20khatri
@MrRavi20khatri 3 жыл бұрын
Wise way to use egg is to make omlet...
@deepankaradhikari5405
@deepankaradhikari5405 4 жыл бұрын
In mid of this video, I realize ki abb pen ghumana aa gya
@kitkat584
@kitkat584 22 күн бұрын
I almost solved it. It fits with Binary Search + Recursion (for considering the two possibilities)
@Shobhitgupta01
@Shobhitgupta01 10 ай бұрын
I Still have problem understanding why we are using MCM technique here. MCM us generally used when we need to create subgroups in an array/string and calculate something. wg A1A2A3 => (A1)(A2A3), or T&F|T => (T&(F|T)). K is meant to create a partition and we recursively find partitions on existing ones. Can't visualize here why we need to do this and why cant we use binary search. Please help
@mathematicsquestions
@mathematicsquestions 2 жыл бұрын
It seems recursion rather than dynamic programming. Which part of it defines dynamic programming used? Please explain.
@kalyanking1080
@kalyanking1080 3 жыл бұрын
after seeing this problem my reaction 26:50
@__RohitDevar
@__RohitDevar 3 жыл бұрын
😄😄😄
@arjunkhanna1803
@arjunkhanna1803 2 жыл бұрын
Can we use binary search on answer?
@avmovies7930
@avmovies7930 3 ай бұрын
Please complete full DP series
@manojnavinjamuri5867
@manojnavinjamuri5867 Жыл бұрын
thank you soo muchhh
@mahipalsingh-yo4jt
@mahipalsingh-yo4jt 4 жыл бұрын
great explanation sir ........
@prayagpatel9136
@prayagpatel9136 2 жыл бұрын
worst case basically implies "guarantee of k we have found" right?
@David-mk8kh
@David-mk8kh Жыл бұрын
I understood all the problems before with a great ease, but this problem is a bit different and confusing then all the previous problmes😵‍💫😵‍💫🥴😢😬
@girikgarg8
@girikgarg8 2 жыл бұрын
I had a doubt here.... in MCM pattern we usually consider invalid input... so here why did we consider smallest valid input?
@motivational_dosee
@motivational_dosee 2 жыл бұрын
This problem seems very simple but logic is too deep and confusing 💀
@anantjain1263
@anantjain1263 3 жыл бұрын
Why we are adding 1 + in max I didn't understand the answer , please help
@amanburman9114
@amanburman9114 3 жыл бұрын
At that iteration, you are dropping an egg to check whether it will break or not. The question asks minimum no. of "attempts", so when you drop an egg, you increase your "count of attempts" by 1. Meaning you "attempted" to check whether egg will break or not. Hope you understand.
@vaibhavjadhav8987
@vaibhavjadhav8987 4 жыл бұрын
great video bro... really helpful....but 50th floor se egg kon drop karta hai yaar(just for fun)
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
Thanks !! Placement k liye sb krna pdhta h bhai 😂😂
@chiragkushwaha546
@chiragkushwaha546 4 жыл бұрын
@@TheAdityaVerma 🤣🤣🤣
@tanmay6441
@tanmay6441 2 жыл бұрын
bhaiya ham middle se kyun nhi faik sakte? usme bina mcm ke hojayega binary search jese kuch
@pavankumar-cy6mg
@pavankumar-cy6mg 3 жыл бұрын
what do you mean by break at any floor in coding
@shiwamjaiswal9653
@shiwamjaiswal9653 4 жыл бұрын
What I have understood from the "worst case" is if the no of attempts are maximum by breaking the eggs to find the threshold floor (i.e. by going down) then we keep breaking till we have one egg remaining. Else we don't break any eggs and go to the top most floor and count the number of attempts to reach there. And in the final answer we take maximum of both the answers. That means we never stop in between the floors. This is the reason why we take Base Conditions : if(e==1) return f; // if we have one egg left we simply return the number of floors given considering that in worst case we don't break any egg and reach to the given number of floor. if(f==0||f==1) return f; // if we have only one floor/No floor then that is the worst case regardless of the number of eggs we have. Can anyone validate my thought process?
@ekanshsharma4293
@ekanshsharma4293 4 жыл бұрын
Yes it's completely correct
@devendrasingh4776
@devendrasingh4776 4 жыл бұрын
We are stopping at every floor because for each floor we again have to think for two case s
@bhavneetsingh2000
@bhavneetsingh2000 4 жыл бұрын
I still didn't get why we maximized for worst case?
@kartiksaini5619
@kartiksaini5619 2 жыл бұрын
i think this can be solved using binary search as well ,kindly correct me if i'm wrong ,cuz i haven't tried solving it using bsearch but while going through i got an idea
@pranjal-barnwal
@pranjal-barnwal 2 жыл бұрын
Binary Search will pass only for few testcases where eggs are sufficient (i.e. number of eggs >= log(number of floors) ). Like if eggs = 2 & floors =100, you can solve this with binary search as you would need in worst case 7 eggs
@madhurbhargava
@madhurbhargava 4 жыл бұрын
Bro, you need to use binary search in place of your for loop, otherwise this will give TLE despite memoization on LC.
@mainaksanyal9515
@mainaksanyal9515 4 жыл бұрын
Even I find it similar to binary search problem. We can split it in two halfs always to check if the egg breaks or not. And lets suppose we are at mth position in doing so and have only 1 more egg left. Then worst case can be (n-1)+(m-1) cases. And if f is smaller that 2^n then it is more easy to find. I don't get why we have to make this ques analogous to MCM!?
@madhurbhargava
@madhurbhargava 4 жыл бұрын
@@mainaksanyal9515 That is actually a better/more efficient way of doing this. Although for small inputs, bhai ne bahut accha samjhaya hai.
@srini9
@srini9 4 жыл бұрын
बहुत बदिया भाई
@manthoshn4386
@manthoshn4386 4 жыл бұрын
binary search will work when you have unlimited no of eggs for trials,,, here we have limited eggs
@madhurbhargava
@madhurbhargava 4 жыл бұрын
@@manthoshn4386 do enlighten me why the binary search should not work on limited I/p. Also, do show me a piece of code which passes on lc without a d&c algo for this problem.
@dhruvbhanderi3407
@dhruvbhanderi3407 3 жыл бұрын
can't we apply binary search?
@melbinthomas2199
@melbinthomas2199 4 жыл бұрын
Awesome explanation
@akhiranandanpallepogu7337
@akhiranandanpallepogu7337 Жыл бұрын
Bro casually dropped f bomb at 26:48 😂
@learntogrow6132
@learntogrow6132 2 жыл бұрын
this ques would be much practical if thereshold was given and we need to calculate the ways
@keshavraghav3896
@keshavraghav3896 2 жыл бұрын
Can we do this problem using binary search.?
@tanujaSangwan
@tanujaSangwan 2 ай бұрын
All these questions are literally so tough. scrambled eggs, egg dropping, expression to True/False. Do people actually solve it in the first go? Or I am just dumb.
@sujayshanbhag2055
@sujayshanbhag2055 Жыл бұрын
why find out minimum of worst cases though? it is easy to understand looking at the code, that it is taking minimum of worst cases. But why tho? I understand that to be sure we might need to calculate max of both recursion calls, but why take minimum of all such cases. shouldnt we also take worst case here to be sure that a solution can be reached in the given number of drops, any way we try to start to drop.
@cripz4203
@cripz4203 4 жыл бұрын
Can we get more optimised answer if we iterate k just like we do for binary search rather than linear.
@0anant0
@0anant0 4 жыл бұрын
Yes, since the floors are already a 'sorted array'. If broken >= unbroken, hi = mid, else lo = mid+1
@aishuo07
@aishuo07 3 жыл бұрын
nope
@Kuriocity
@Kuriocity 3 жыл бұрын
For Binary Search, we ll require log n eggs but here we have limited
@satwikjain6177
@satwikjain6177 Жыл бұрын
if you understand the problem statement clearly you can start from here 11:40
@nitinchandel8103
@nitinchandel8103 3 жыл бұрын
can some body tell me what is the role of no. of egg here , even if we drop a single egg it is considered as an attempt
@kapil6392
@kapil6392 3 жыл бұрын
why can't we use simple binary search till no: of eggs left is 1 and then for the last egg we can use simple loop within the range.
@rkalpeshk
@rkalpeshk 3 жыл бұрын
JAVA CODE : static int fun(int egg, int floor) { if (floor == 0 || floor == 1) return floor; if (egg == 1) return floor; int min = Integer.MAX_VALUE; for (int k = 1; k temp) min = temp; } return min; }
@dhirisalasaisankar4338
@dhirisalasaisankar4338 Жыл бұрын
Why recursive calls are under for loop
@gouravchalotravlog
@gouravchalotravlog 2 жыл бұрын
Ya kush binary search jasa question lag raha ha kya is ma BS lag sakti ha ? bhiya ji
@SwikarP
@SwikarP 2 жыл бұрын
great video
@SurjitSingh14-c6i
@SurjitSingh14-c6i 3 жыл бұрын
Can't it be solved by binary search
@aanchalsingh5782
@aanchalsingh5782 3 жыл бұрын
Why can't we apply binary search in this ??
@ARYAN_BAJPAI_IIT_BHU
@ARYAN_BAJPAI_IIT_BHU 5 ай бұрын
can we use binary search
@abhisheksuryavanshi9675
@abhisheksuryavanshi9675 4 жыл бұрын
Please upload new videos..May is about to get over
@anjalichoudhary5467
@anjalichoudhary5467 4 жыл бұрын
Thank you :)
@TheAdityaVerma
@TheAdityaVerma 4 жыл бұрын
You're welcome!
@bharataaryavrat4067
@bharataaryavrat4067 3 жыл бұрын
can you see my mistake ,i am geeting wrong answer #include using namespace std; #define ll long long // string dp[4001][4001]; vectordp(4001,vector(4001,"")); int main() { string s1,s2; cin>>s1>>s2; ll n=s1.length(); ll m=s2.length(); for(ll i=0;i
@pqazx1
@pqazx1 4 жыл бұрын
how to print the ans for each floor??
@shivangishukla2629
@shivangishukla2629 4 жыл бұрын
amazing explanation!
@shubhamchaudhary8688
@shubhamchaudhary8688 4 жыл бұрын
Worst case kind of means jb bhi ham jo choose kare uske opposite mein answer/crticial point hai isliye ham hamesha max lenge!
@Finimals
@Finimals 2 жыл бұрын
Why cant we do it from Binary search eg 14 floors, worst case is 14th floor, so first solve at 7 and it will break , then solve 11 , then 13 and then 14 ans 4 attempts
@kartikwar8022
@kartikwar8022 2 жыл бұрын
binary search to use hua hi ni isme. I think binary search se aur optimise ho sakta hai
@__RohitDevar
@__RohitDevar 3 жыл бұрын
26:49 😄😄
@sleepypanda7172
@sleepypanda7172 2 жыл бұрын
Gotcha! Thanks a lot!
@sonianarendramodi2605
@sonianarendramodi2605 2 жыл бұрын
26:49 nice
@ankurnarayansingh3031
@ankurnarayansingh3031 2 жыл бұрын
at 26:53 engineers instinct. 🤣
@bhavyaaggarwal8558
@bhavyaaggarwal8558 2 жыл бұрын
26:50 iconic word of this video😂😂
@tanmaytyagi7031
@tanmaytyagi7031 3 жыл бұрын
cant we use binary search?
44 Egg Dropping Problem Memoization
15:43
Aditya Verma
Рет қаралды 66 М.
41 Scrambled String Recursive
45:48
Aditya Verma
Рет қаралды 142 М.
龟兔赛跑:好可爱的小乌龟#short #angel #clown
01:00
Super Beauty team
Рет қаралды 133 МЛН
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 21 МЛН
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 5 МЛН
Egg Dropping Puzzle | Problem of the Day : 01/08/22 | Yash Dwivedi
17:14
GeeksforGeeks Practice
Рет қаралды 4 М.
39  Evaluate Expression to True  Boolean Parenthesization Recursive
40:00
Can you solve the egg drop riddle? - Yossi Elran
4:47
TED-Ed
Рет қаралды 8 МЛН
19  Longest common subsequence Recursive
27:42
Aditya Verma
Рет қаралды 293 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41