#3748
Count Stable Subarrays
international master · 1925 · lc hard +32 · 32.3% accepted · 61 likes · top 10%
Description
Given an integer array nums and a 2D array queries where queries[i] = [li, ri], for each query return the number of subarrays entirely within nums[li..ri] that are stable (contain no inversions, meaning they are non-decreasing).
Code
1
2
3