{"id":"1fe4ab82-0219-4696-ac67-7fc0c83e4dc5","name":"Egg Drop","description":"1. You are given two integers N and K. N represents the number of eggs and K represents the number of floors in a building.\r\n2. You have to find the minimum number of attempts you need in order to find the critical floor in the worst case while using the best strategy.\r\n3. The critical floor is defined as the lowest floor from which you drop an egg and it doesn't break. \r\n4. There are certain which you have to follow -\r\n a. All eggs are identical.\r\n b. An egg that survives a fall can be used again.\r\n c. A broken egg can't be used again.\r\n d. If the egg doesn't break at a certain floor, it will not break at any floor below.\r\n e. If the egg breaks at a certain floor, it will break at any floor above.","inputFormat":"Two integers N and K","outputFormat":"Check the sample output and question video.","constraints":"1 <= N <= 100\r\n1 <= k <= 50","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int eggDrop(int n, int k){\r\n\t\t//write your code here\r\n\r\n\t\treturn 0;\r\n\t} \r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\t//n -> number of eggs and k -> number of floors\r\n\t\tint n = scn.nextInt();\r\n\t\tint k = scn.nextInt();\r\n\t\tSystem.out.println(eggDrop(n,k));\r\n\t}\r\n\t\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"3\r\n10","sampleOutput":"4\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"6b6d0ac2-59e0-41df-a848-789813473187","name":"Egg Drop","slug":"egg-drop","type":1}],"next":{"id":"d7ab2492-c171-4ec1-8934-94b638357ed7","name":"EGG DROP MCQ","type":0,"slug":"egg-drop-mcq"},"prev":{"id":"ae4d1501-40b1-489b-b8a4-4f87f579956d","name":"Optimal Strategy For a Game","type":3,"slug":"optimal-strategy-for-a-game"}}}

Egg Drop

1. You are given two integers N and K. N represents the number of eggs and K represents the number of floors in a building. 2. You have to find the minimum number of attempts you need in order to find the critical floor in the worst case while using the best strategy. 3. The critical floor is defined as the lowest floor from which you drop an egg and it doesn't break. 4. There are certain which you have to follow - a. All eggs are identical. b. An egg that survives a fall can be used again. c. A broken egg can't be used again. d. If the egg doesn't break at a certain floor, it will not break at any floor below. e. If the egg breaks at a certain floor, it will break at any floor above.

{"id":"1fe4ab82-0219-4696-ac67-7fc0c83e4dc5","name":"Egg Drop","description":"1. You are given two integers N and K. N represents the number of eggs and K represents the number of floors in a building.\r\n2. You have to find the minimum number of attempts you need in order to find the critical floor in the worst case while using the best strategy.\r\n3. The critical floor is defined as the lowest floor from which you drop an egg and it doesn't break. \r\n4. There are certain which you have to follow -\r\n a. All eggs are identical.\r\n b. An egg that survives a fall can be used again.\r\n c. A broken egg can't be used again.\r\n d. If the egg doesn't break at a certain floor, it will not break at any floor below.\r\n e. If the egg breaks at a certain floor, it will break at any floor above.","inputFormat":"Two integers N and K","outputFormat":"Check the sample output and question video.","constraints":"1 <= N <= 100\r\n1 <= k <= 50","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int eggDrop(int n, int k){\r\n\t\t//write your code here\r\n\r\n\t\treturn 0;\r\n\t} \r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\t//n -> number of eggs and k -> number of floors\r\n\t\tint n = scn.nextInt();\r\n\t\tint k = scn.nextInt();\r\n\t\tSystem.out.println(eggDrop(n,k));\r\n\t}\r\n\t\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"3\r\n10","sampleOutput":"4\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"6b6d0ac2-59e0-41df-a848-789813473187","name":"Egg Drop","slug":"egg-drop","type":1}],"next":{"id":"d7ab2492-c171-4ec1-8934-94b638357ed7","name":"EGG DROP MCQ","type":0,"slug":"egg-drop-mcq"},"prev":{"id":"ae4d1501-40b1-489b-b8a4-4f87f579956d","name":"Optimal Strategy For a Game","type":3,"slug":"optimal-strategy-for-a-game"}}}
plane

Editor


Loading...

Egg Drop

hard

1. You are given two integers N and K. N represents the number of eggs and K represents the number of floors in a building. 2. You have to find the minimum number of attempts you need in order to find the critical floor in the worst case while using the best strategy. 3. The critical floor is defined as the lowest floor from which you drop an egg and it doesn't break. 4. There are certain which you have to follow - a. All eggs are identical. b. An egg that survives a fall can be used again. c. A broken egg can't be used again. d. If the egg doesn't break at a certain floor, it will not break at any floor below. e. If the egg breaks at a certain floor, it will break at any floor above.

Constraints

1 <= N <= 100 1 <= k <= 50

Format

Input

Two integers N and K

Output

Check the sample output and question video.

Example

Sample Input

3 10

Sample Output

4

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode