All Posts

Leetcode 1546: Maximum Number of Non-Overlapping Subarrays With Sum Equals Target

Given an integer array nums and an integer target, return the maximum number of non-empty, non-overlapping subarrays that sum up to the target.

Leetcode 1589: Maximum Sum Obtained of Any Permutation

You are given an array of integers nums and a list of requests, where each request specifies a range in the array. The ith request asks for the sum of all elements from nums[starti] to nums[endi], inclusive. Your task is to determine the maximum total sum of all requests for any permutation of nums.

Leetcode 1590: Make Sum Divisible by P

Given an array of positive integers nums and an integer p, your task is to remove the smallest subarray (contiguous elements) such that the sum of the remaining elements is divisible by p. If it’s impossible, return -1. Note that the entire array cannot be removed.

Leetcode 1658: Minimum Operations to Reduce X to Zero

You are given an array of integers nums and an integer x. In each operation, you can either remove the leftmost or rightmost element from the array and subtract its value from x. The task is to determine the minimum number of operations required to reduce x to exactly 0, or return -1 if it’s not possible.

Leetcode 1664: Ways to Make a Fair Array

You are given an array nums of integers. You are allowed to remove one element from the array at any index. After removing the element, the remaining array is called ‘fair’ if the sum of the values at the odd indices is equal to the sum of the values at the even indices. The task is to find how many indices you can remove such that the resulting array is fair.

Leetcode 1674: Minimum Moves to Make Array Complementary

You are given an integer array nums of even length n and an integer limit. In one move, you can replace any element of nums with another integer between 1 and limit (inclusive). The array nums is complementary if for all indices i, nums[i] + nums[n - 1 - i] equals the same number. Return the minimum number of moves required to make nums complementary.