#3187
Peaks in Array
international master · 2055 · lc hard +32 · 27.2% accepted · 142 likes · top 5%
Description
A peak in nums is an interior element strictly greater than both neighbors. Given nums and two-type queries, process them in order: type 1 [1, li, ri] counts peaks in the subarray nums[li..ri] (endpoints of the subarray cannot be peaks); type 2 [2, indexi, vali] sets nums[indexi] = vali. Return the answers to all type-1 queries.
Code
1
2
3