Mike and Gems

Easyrubrik

Problem Overview

  • Determine the maximum number of gems Mike can collect in order while keeping stamina never negative.
  • Input: n and array a_i (gem potencies). Output: one integer. Constraints: 1 ≤ n ≤ 1e5, −1e9 ≤ a_i ≤ 1e9.
  • At each gem, Mike must pick or destroy; picking changes stamina by potency and cannot drop below zero.
  • Set on planet AFWP-700, traveling from Base A to Base B with gems that boost or reduce stamina.
  • A Rubrik interviews coding interview problem and common 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: