Hard
Meta

Find the Breaking Floor with Two Bulbs Coding / DSA Interview

Given two identical bulbs and a building with F floors, find the minimum critical floor at which a bulb breaks when dropped, while minimising the worst-case number of drops.

1. Problem Statement

You have two identical bulbs and a building with F floors (numbered 1 to F). There is some unknown critical threshold T (1 ≤ T ≤ F + 1) such that: - A bulb survives if dropped from any floor ≤ T - 1. - A bulb breaks if dropped from any floor ≥ T. - T = F + 1 means the bulb survives from every floor in the building. A broken bulb cannot be reused. Your goal is to identify T using the minimum possible worst-case number of drops. Start with any clarifying questions, then explain your approach.

2. Live Coding Format

Work in the provided coding workspace while explaining your decisions to the live interviewer. Validation may use inline tests, examples, comments, or a verbal walkthrough.

3. Key Focus Areas

  • 1
    Two-bulb constraint modelling
  • 2
    Why binary search fails with only two bulbs
  • 3
    Triangular-step strategy derivation
  • 4
    Optimal step-size calculation
  • 5
    Worst-case drop count analysis

4. What Strong Candidates Should Demonstrate

  • Model the two-bulb constraint: after the first bulb breaks you must use a linear scan with the second.
  • Derive the triangular-step strategy: drop the first bulb at intervals of n, n-1, n-2, … floors.
  • Compute the optimal step size for a given floor count (smallest n with n*(n+1)/2 ≥ F).
  • Analyse worst-case drops and compare with naive binary search (which requires more than two bulbs).

Want interactive feedback?

Practice this problem in the live coding workspace while the interviewer probes your clarification, implementation, trade-offs, and validation.

Start Interview

Core Concepts

Math / CombinatoricsSearch StrategyWorst-Case Optimisation