Egg Dropping Puzzle with 2 Eggs and 100 Floors #interview #SimpleLogic #dsa #puzzle #job #career

preview_player
Показать описание
Egg Dropping Puzzle with 2 Eggs and 100 Floors | Microsoft Interview Puzzles | Google Interview Puzzles #SimpleLogic #dsa #puzzle #job #career

Question :-
A building has 100 floors. One of the floors is the highest floor an egg can be dropped from without breaking.
If an egg is dropped from above that floor, it will break. If it is dropped from that floor or below, it will be completely undamaged and you can drop the egg again.
There are two eggs Given, find the highest floor an egg can be dropped from without breaking, with as few drops as possible

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.

**************************************************************************

Solution :-

If the first egg breaks at first attempt, since we have only one more egg left, we will have to try sequentially from 1 to n.
So the worst case number of attempts will be n

If the first egg doesn't break at nth floor, the question is which floor we try next?
Lets say we step up (n-x) floors and try at n + (n-x)th floor. So the worst case number of attempts will be 1 + (n-x).

Since we are trying to minimize the worst case number of attempts, we should go for a uniform solution that is the number of attempts should be the same with each step up.
n = (n-x) + 1
x =1

This means if first egg doesn't break at nth floor, we need to try at (n + n-1)th floor. Similarly if the first egg doesn't break at (n + n-1), we need to try at (n+ (n-1) + (n-2)) floor and so on till we reach 100 the floor
So we now have this equation

= n + (n-1) + (n-2) + ... 1 greater than or equal to 100
= n(n+1)/2 greater than or equal to 100
= n greater than or equal to 14

So we need to try at floors 14, (14 + 13), (14+13+12),....till we reach 100
If first egg breaks at 14 we try from 1 to 13 sequentially with the second egg - worst case attempts will be 14 if egg breaks at 13th floor.
If first egg doesn't break at 14 , try at 27, if it breaks try sequentially from 15 to 26 with the second egg - worst case number of attempts is again 14 if egg breaks at 26th floor.

**************************************************************************

#gfg #dsa #programming #Egg #Dropping #Puzzle
#interview #puzzle #eggdropping #SimplyLogical #MicrosoftInnterview #googleinterview

Keywords

egg dropping problem
egg dropping problem dynamic programming
egg dropping puzzle
egg dropping problem binary search
egg dropping challenge
egg dropping striver
egg dropping puzzle with 2 eggs and k floors
egg dropping problem leetcode
egg dropping from space
egg dropping problem dp
egg dropping problem love babbar
egg dropping dynamic programming
egg dropping problem recursive
egg dropping puzzle dp-11
egg dropping puzzle striver
egg dropping puzzle c++
egg dropping puzzle solution
Solution of egg dropping puzzles
Solution of egg dropping problem
Solution of egg dropping

✨ Hashtags ✨

#interview #career #job #manualtesting #howto #tutorial #guide #tipsandtricks #quickstart #getstarted #beginner #advanced #corporate #corporateevents #corporatelife #techcareers #SQL #NoSQL #RDBMS #GoogleSde #Tech #SoftwareEngineering #Jobs #Career #ComputerScience #FAANGM #FAANG #DTU #engineering #internship #college #DSA #Freshers

#75HardChallenge
#75Hard
#75HardLife
#75HardJourney
#75HardStrong
#75HardSuccess
#75HardTransformation
#75HardMindset
#75HardMotivation
#75HardResults
#75HardAccountability
#75hardcommunity

SQL ALTER TABLE
SQL Table Modification
Database Schema Changes
SQL Table Structure
Modify Table in SQL
Altering Database Tables
SQL Table Design
Database Table Alteration
SQL Schema Management
Database Development
SQL Data Modeling
SQL DDL Commands
SQL Table Properties
SQL Database Management
SQL Database Administration
SQL Database Design
SQL Server Management
SQL Database Changes
SQL Column Alteration
SQL Database Tutorial

--------------------------------------------------------------------------------------------------

#sql
#database
#datamanagement
#sqltutorial
#databasedesign
#databasemanagement
#structuredquerylanguage
#datamanipulation
#DatabaseSchema
#sqlcommands
#databasedevelopment
#sqlqueries
#databaseprogramming
#databaseadministrator
#sqlserver
#mysql
#postgresql
#sqlite3
#datamodelling
Рекомендации по теме