Company: Mathworks_8aug
Difficulty: medium
Array Nullification Problem Description You are given two arrays, change and arr , of lengths n and m , respectively. In each operation, you can perform one of the following: You can decrement any element of arr by 1. If change[i] == 0 and arr[change[i]] == 0 , you can change that element to NULL. Assume 1-based indexing and find the minimum number of operations required to change all elements of the array to NULL, or report -1 if not possible. Example: n = 4, m = 2 change = [0, 1, 0, 2] arr = [1, 1] Operations sequence: Decrement arr[1]: [0, 1] Change arr[1] to NULL since change[2] = 1 and arr[1] = 0: [NULL, 1] Decrement arr[2]: [NULL, 0] Change arr[2] to NULL since change[4] = 2 and arr[2] = 0: [NULL, NULL] The answer is 4. Function Description Complete the function getMinOperations in the editor with the following parameter(s): int change[n]: an array of integers int arr[m]: an array of integers Returns int: the minimum number of operations required to change all the elements to NUL