A peak in an array
arr
is an element that is greater than its previous and next element inarr
.You are given an integer array
nums
and a 2D integer arrayqueries
.You have to process queries of two types:
queries[i] = [1, li, ri]
, determine the count of peak elements in the subarraynums[li..ri]
.queries[i] = [2, indexi, vali]
, changenums[indexi]
tovali
.Return an array
answer
containing the results of the queries of the first type in order.Notes:
- The first and the last element of an array or a subarray cannot be a peak.
c++
1 |
|