result to 1 (since we will be multiplying differences).prev_index to -1 to store the index of the previous 1.nums using an index i.
nums[i] is 1, check if prev_index is not -1.
result by the difference (i - prev_index) and take modulo 10^9 + 7.prev_index to the current index i.prev_index is still -1, return 0 as there are no 1s in the array.result as the final answer.