RubrikOA #15
Get Minimum Operations
估计中等评测数据准备中,可先阅读题面
Given two arrays change and arr that consist of n and m integers respectively.
In the ith operation, one of the two operations can be performed:
you can choose to decrement any element of arr by 1 or do nothing.
if change[i] > 0 and arr[change[i]] = 0, it can be changed to NULL.
Assume indexing starts from 1, find the minimum number of operations required to change all the elements of the array to NULL or report -1 if it is not possible.
Function Description
Complete the function getMinOperations in the editor below.
getMinOperations has the following parameter(s):
int change[n]: an array of integersint arr[m]: an array of integers Returnsint: the minimum number of operations required to change all the elements toNULL, or-1if it is not possible
Constraints
:o