Mike and Gems
Asked at Rubrik · Coding Questions · Difficulty: Medium
Mike walks a path past gems in a fixed order. Each gem has a potency (which may be negative). For each gem he either picks it up (adding its potency to his stamina) or destroys it (skips it). His stamina must never become negative at any point during the walk. Return the maximum number of gems he can collect.
Loading the problem…