Prefix Sum

Prefix Sum

Twenty questions on prefix sums, for answering range-sum and cumulative queries without recomputing from scratch.

Ant on the Boundary

easy
An ant is on a boundary.

Check if All the Integers in a Range Are Covered

easy
You are given a 2D integer array ranges and two integers left and right.

Count Partitions with Even Sum Difference

easy
You are given an integer array nums of length n.

Find Pivot Index

easy
Given an array of integers nums, calculate the pivot index of this array.

Find the Highest Altitude

easy
There is a biker going on a road trip.

Find the Middle Index in Array

easy
Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).

Find the Pivot Integer

easy
Given a positive integer n, find the pivot integer x such that: Return the pivot integer x.

Left and Right Sum Differences

easy
You are given a 0-indexed integer array nums of size n.

Longest Subsequence With Limited Sum

easy
You are given an integer array nums of length n, and an integer array queries of length m.

Make Array Elements Equal to Zero

easy
You are given an integer array nums.

Maximum Population Year

easy
You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.

Maximum Score After Splitting a String

easy
Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e.

Minimum Positive Sum Subarray

easy
You are given an integer array nums and two integers l and r.

Minimum Value to Get Positive Step by Step Sum

easy
Given an array of integers nums, you start with an initial positive value startValue.

Points That Intersect With Cars

easy
You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line.

Running Sum of 1d Array

easy
Given an array nums.

Sum of All Odd Length Subarrays

easy
Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr.

Sum of Variable Length Subarrays

easy
You are given an integer array nums of size n.

Apply Operations to Make All Array Elements Equal to Zero

medium
You are given a 0-indexed integer array nums and a positive integer k.

Binary Subarrays With Sum

medium
Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.