Ad
  • Custom User Avatar

    I agree 100% that this is an off-by-one error. If, as the description suggests, the target_floor (highest floor before the egg breaks) is 1 <= target_floor <= max_floor, and we are to find max_floor, then (n, m) = (0, 0) implies that max_floor = 1.

    If you instead use the definition that 0 <= target_floor <= max_floor then this is equivalent to solving the problem from the other perspective and then subtracting 1 from the resulting max_floor. Indeed, if you consider the algorithm for finding the target_floor, and if from the start it is assumed that k <= target_floor for some k, then it is useless for the algorithm to check any floors at or below k. This effectively shifts the algorithm's search by k - 1 places and thus shifts the resulting max_floor by the same amount.

  • Custom User Avatar

    The 0 answers do make sense, but that the target floor can't be 0 is weird: what if the egg breaks even if dropped from floor 1? then there is no maximum floor from which the egg won't crack and the logical answer (to the actual floor determination problem) would be 0.

    And all of this is sort of a problem because it can lead to some off-by-one errors due to this 'floor zero' thing. I think this has to be clarified somehow in the description.

  • Custom User Avatar

    With 0 eggs and 1 floor you don't know if the egg would break while dropping from floor #1 or not, as you have 0 eggs to test. So it's proper to return zero here as if a house would have 0 floors, we can say that throwing eggs from that height won't break them even having no eggs.

  • Custom User Avatar

    Question says: target floor can be any floor between 1 to this maximum height?
    Some of the answers are '0'

    This doesn't make any sense. For the case where you have no eggs, the max height should be 1.
    Either that or the target floor should be any floor between 0 and the max height.