Find Maximum Zeroes

Problem Overview

  • Determine the maximum number of zeroes achievable in an array by repeatedly decrementing a zero-free prefix without creating negatives.
  • Input: array arr of n positive integers; Output: a single integer (max zeroes); Constraints: 1 ≤ n ≤ 2e5, 1 ≤ arr[i] ≤ 1e9.
  • Real-world context: an analytics team favors zero and avoids negative values while adjusting prefixes.
  • This is an Amazon interviews coding interview problem and interview question.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: