Company: UIpath_5sep
Difficulty: medium
Count Good Arrays Problem Description Numbers must be assigned to classmates represented in an array. An arrangement is considered good if the absolute difference between any two adjacent students is at most 1. The input array contains some missing elements marked as 0. Your task is to find the total number of ways to replace these missing elements with arbitrary integers to form a good array. Since the answer can be large, return it modulo (10 9 + 7). For example, if arr = [0, 0] , there are 9 ways to replace the zeros to make the array good: [0,0] [0,1] [1,0] [1,1] [1,2] [2,1] [2,2] [3,2] [2,3] In each of these arrays, the absolute difference between consecutive elements is at most 1. Complete the function countGoodArrays in the editor with the following parameters: int arr[n] : an array of integers Returns: int : the number of ways to replace missing elements to form a good array, modulo (10 9 + 7) int countGoodArrays(std::vector arr) { // Function implementation } Examples Example