Problem Statement: You are given two eggs and a 100-floor building. The challenge is to determine the highest floor from which you can drop an egg without it breaking, using the least number of drops in the worst-case scenario.
Approach:
Optimal Strategy Explained:
Start by dropping the first egg from the 10th floor, then the 19th, 27th, and so on, decreasing the increment by one each time. The floors to drop from are determined by the formula: x, x + (x-1), x + (x-1) + (x-2), ... where x is the starting floor increment.
When the first egg breaks, you then use the second egg to test each floor one by one within the last interval.
Mathematical Justification: The increments decrease by one each time to ensure that the sum of drops covers all floors up to 100 with the least number of total drops.
Problem Statement: You are given a linked list that may contain a loop. The task is to detect if a loop exists and, if so, find the starting node of the loop.
Approach:
Detecting the Loop:
slow and fast. Move slow by one node and fast by two nodes in each step.slow and fast pointers will eventually meet inside the loop.Finding the Starting Node of the Loop:
Once the loop is detected, keep one pointer at the meeting point and move the other pointer to the head of the linked list.
Move both pointers one step at a time; the point at which they meet will be the start of the loop.
Detailed Steps:
slow and fast, at the head of the list.slow one step and fast two steps in each iteration.slow equals fast, a loop is detected.Two eggs and a 100-floor building.
What is the best possible method to find from which floor an egg will break?
The following metrics were computed from 1 interview experience for the Oracle Software Engineer role in Kharagpur, West Bengal.
Oracle's interview process for their Software Engineer roles in Kharagpur, West Bengal is extremely selective, failing the vast majority of engineers.
Candidates reported having very good feelings for Oracle's Software Engineer interview process in Kharagpur, West Bengal.