You are given an integer array
numsof lengthnand a 2D integer arrayqueries.A subarray
nums[i..j]is called a peak subarray if:
- Its length is at least 3.
- There exists an index
ksuch thati < k < jand:
nums[k] > nums[k - 1]nums[k] > nums[k + 1]You have to process queries of two types:
[1, l_i, r_i]: Calculate the number of peak subarrays fully contained withinnums[l_i..r_i].[2, index_i, val_i]: Updatenums[index_i]toval_i. This update applies to all subsequent queries.Return an array
answer, whereanswer[i]is the answer to thei^thquery of type 1 in the order they appear.