Skip to main content

4 docs tagged with "Prefix Sum"

View all tags

209. Minimum Size Subarray Sum

Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead.

3354. Make Array Elements Equal to Zero

You are given an integer array nums. Start by selecting a starting position curr such that nums[curr] == 0, and choose a movement direction of either left or right.

3903. Smallest Stable Index I

You are given an integer array nums of length n and an integer k. For each index i, define its instability score as max(nums[0..i]) - min(nums[i..n - 1]).In other words max(nums[0..i]) is the largest value among the elements from index 0 to index i.min(nums[i..n - 1]) is the smallest value among the elements from index i to index n - 1.An index i is called stable if its instability score is less than or equal to k.Return the smallest stable index. If no such index exists, return -1.

3904. Smallest Stable Index II

You are given an integer array nums of length n and an integer k.For each index i, define its instability score as max(nums[0..i]) - min(nums[i..n - 1]).In other words:max(nums[0..i]) is the largest value among the elements from index 0 to index i.min(nums[i..n - 1]) is the smallest value among the elements from index i to index n - 1.An index i is called stable if its instability score is less than or equal to k.Return the smallest stable index. If no such index exists, return -1.