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.
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.
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.
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.
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.