# Posts with tag 'prefix sum'

## Maximum Sum Rectangle with Condition

Given a two-dimensional integer matrix matrix and an integer k, return the largest sum of a rectangle ≤ k.

## Maximum Sum Removing K Numbers From Ends

You are given a list of integers nums and integer k. Return the maximum sum of elements that you can remove given that you must pop exactly k times, where ea...

## Range Query on Two Dimensional List

Implement a data structure with the following methods:

## Longest Zero Sublist Sum

Given a list of integers nums, which contains either -1 or 1, return the length of the longest sublist that sums to 0.

## Stacks

Given a list of list of positive integers stacks, you can take any stack(s) in stacks and pop any number of elements. Return the maximum sum that can be achi...

## Max Sum of Two Non-Overlapping Lists

Given a list of integers nums and integers a and b, return the max sum of two non-overlapping sublists in nums which have lengths a and b.

## Largest Sum of 3 Non-Overlapping Sublists

Given a list of integers nums and an integer k, return the largest sum of three non-overlapping sublists of nums each of size k.

## Number of K-Length Sublists with Average at Least Target

Given a list of integers nums, and integers k and target, return the number of sublists whose length is k and its average value ≥ target.

## Largest Sublist Sum

Given a list of integers nums, return the sum of a non-empty contiguous sublist with the largest sum.

## Uber Pool

You are given a two-dimensional integer list requested_trips containing [start_x, end_x, num_passengers], and an integer capacity. Each requested trip asks t...

## Range Update

You are given a list of integers nums and a two-dimensional list of integers operations. Each operation is of the following form: [L, R, X], which means that...

## Range Query on a List

Implement a data structure with the following methods:

## Number of Sublists With Sum of Target

Given a list of integers nums and an integer target, return the number of sublists whose sum is equal to target.

## Minimum Initial Value for Positive Prefix Sums

You are given a list of integers nums. Return the minimum positive value we can append to the beginning of nums such that prefix sums of the resulting list c...

## Minimize Amplitude After Deleting K-Length Sublist 🎄

You are given a list of integers nums and an integer k. Given that you must first remove a sublist of length k, return the minimum resulting max(nums) - min(...

## K Prefix

Given a list of integers nums and an integer k, return the maximum possible i where nums[0] + nums[1] + ... + nums[i] ≤ k. Return -1 if no valid i exists.