Skip to main content
Back to problems
Leetcode
Medium
Arrays
Math
Binary Search
Google
Minimum Number Of Seconds To Make Mountain Height Zero

Find the minimum time needed for workers with different speeds to reduce a mountain height to zero.

Acceptance 0%
Problem Statement

You are given a positive mountain height and a set of workers. Worker ii can reduce the mountain by a certain amount over time according to their own speed. In one second, workers may operate in parallel, and the total reduction is the sum of their individual contributions. Your task is to determine the minimum number of seconds required to make the mountain height exactly zero or below.

This is a classic optimization problem: instead of simulating every second directly, determine whether a given amount of time is sufficient, then search for the smallest feasible time.

Input Format

  • An integer representing the mountain height.
  • An array describing the work rate or contribution of each worker.
  • Additional problem-specific parameters may define how each worker contributes over time.

Output Format

Return the minimum number of seconds needed to reduce the mountain height to zero.

Constraints

  • The mountain height and worker parameters are positive integers.
  • The answer fits in a 64-bit signed integer in typical test settings.
  • A feasible solution should run faster than linear simulation over the full answer range.
Examples
Sample cases returned by the problem API.

Example 1

Input

height = 10, workers = [1, 2, 3]

Output

2

Explanation

In 1 second the workers can reduce 1 + 2 + 3 = 6. In 2 seconds they can reduce enough to reach at least 10, so the minimum is 2.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.