Count the Number of Inversions 46:21 【LeetCode】3097. Shortest Subarray With OR at Least K II 09:21 【LeetCode】 3097. Shortest Subarray With OR at Least K II 09:21 【LeetCode】3161. Block Placement Queries 23:16 【LeetCode】3196. Maximize Total Cost of Alternating Subarrays 09...
The idea is to use the strength[i] as the minimum number and find all the subarrays with strength[i] as minimum. Then accumlate strength[i] * sum(subarrays). Get minimum of subarray, use monotonic stack. Get sum of subarray, use prefix sum. left is array is to record first left s...