Back to problems

Get Minimum Operations

Algorithm · Rubrik · Hard

You are given two integer arrays: change of length n and arr of length m. In the i-th operation (1-indexed), you may perform exactly one of the following actions: Decrement any element of arr by 1, or do nothing. If change[i] > 0 and the element arr[change[i]] is currently 0, you may turn that element into NULL. Note that indexing for both arrays starts at 1. Your task is to determine the minimum number of operations needed to convert every element of arr into NULL. If it is…

Checking your access…