Company: UIpath_5sep
Difficulty: medium
Count Good Arrays Problem Description Numbers must be assigned to classmates who are standing in a row, represented by an array arr of n integers. An arrangement is considered good if the absolute difference between the numbers of any two adjacent students is at most 1 , that is, |arr[i] - arr[i+1]| <= 1 for every 0 <= i < n - 1 . Some numbers are missing. A missing number is written as 0 . Every missing number must be replaced by an arbitrary integer, while every number that is not missing keeps its value. A replacement may be any integer at all: 0 , a negative integer, or a positive integer, with no upper limit. (inferred -- the source says "arbitrary integers"; its own example lists [-1, 0, 1] and [1, 0, 1, 2] as valid, so negative values and the value 0 are both allowed as replacements.) Find the total number of ways to replace the missing numbers so that the resulting array is good. Two ways are different if at least one position receives a different value. Since the answ