Company: Rubrik
Difficulty: medium
getMinOperations You are given an array `arr` of `m` non-negative integers and a schedule `change` of `n` integers. The schedule describes `n` operations that happen one after another, in order. Operation `t` (for `1 <= t <= n`) is governed by `change[t]`: If `change[t] = 0`, operation `t` is a **decrement**: you may pick any one element of `arr` that is not `NULL` and whose current value is greater than `0`, and subtract `1` from it. If `change[t] = j` with `1 <= j <= m`, operation `t` is a **NULL** operation on element `j`: you may replace `arr[j]` with `NULL`, and you may do so only if `arr[j]` is currently `0` and is not already `NULL`. At every operation you may also do nothing, but the operation still happens: operations are counted by how many of them have elapsed, not by how many of them you chose to use. Elements are numbered `1` through `m`, and operations are numbered `1` through `n`. Print the smallest `T` such that after operations `1, 2, ..., T` every element