SarthakKeshari / CPP-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
47 stars 132 forks source link

Egg dropping Problem #385

Closed PrakharRathore123 closed 2 years ago

PrakharRathore123 commented 2 years ago

Issue Id you have worked upon -

382

Briefly explain your program logic -

1)If Number of floor is 1 or 0 then return number of floor 2)If the number of egg is 1 then return number of floors 3)If egg breaks then floor will k-1 and egg will be n-1 4)Else floor will be k-i and number of eggs will be same

Test case 1-Number egg are 2 and Number of Floors are 10 so when we throw egg it two possibility it beaks and it doesn't break .If it break then number of egg will be 1 less and we have check for floor -1 (floor where first egg breaks).Because we have to find the threshold floor and we have stop when number of egg is 1 . Test case 2-If number of eggs is 1 then we have to return the number of floor because we have return the worst case.

Screenshots(Attach 2 screenshots of your own input and output) -

Attach here Egg1 Egg2


Checklist:

Eg - If your code follow the below guidelines. Kindly change [] to [x]

All the conditions should be fulfilled for considering your code for merging -

PrakharRathore123 commented 2 years ago

@SarthakKeshari Kindly acknowledge this I have submitted this in dynamic programming folder.

PrakharRathore123 commented 2 years ago

@SarthakKeshari 2 outputs as shown in images with Test case 1-Number egg are 2 and Number of Floors are 10 so when we throw egg it two possibility it beaks and it doesn't break .If it break then number of egg will be 1 less and we have check for floor -1 (floor where first egg breaks).Because we have to find the threshold floor and we have stop when number of egg is 1 . Test case 2-If number of eggs is 1 then we have to return the number of floor because we have return the worst case.

PrakharRathore123 commented 2 years ago

@SarthakKeshari Kindly check