Company: Sharechat_15oct
Difficulty: medium
Count Ways To Create Wave Problem Description The physicists in Hackerland are developing an algorithm to generate wave patterns. An array is considered to form a wave if it satisfies one of these conditions: Elements alternate as: a[1] > a[2] a[4] Elements alternate as: a[1] a[3] a[5]... Given an array arr of n integers, where values are either within the range 1 to m inclusive or -1 , determine how many ways you can replace all the -1 s in the array with integers from 1 to m such that the resulting array forms a wave array. Return the result modulo (10^9 + 7) . Complete the function countWaysToCreateWave in the editor with the following parameters: arr : an array of integers m : an integer Returns: int : the number of ways to replace -1s in the array to make it a wave array, modulo (10^9 + 7) . Examples Example 1: Input: n = 3, arr = [-1, 3, -1], m = 3 Output: 2 Explanation: Suppose n = 3, arr = [-1, 3, -1], m = 3 . The possible ways to replace all -1s in the array such that the resu