Given an array of integers nums and a list of queries, where each query is defined as a subarray nums[li...ri], compute the minimum absolute difference between any two distinct elements in that subarray. If all elements in the subarray are the same, return -1.
You are given an array nums. The alternating sum of a sequence is calculated as the sum of elements at even indices minus the sum of elements at odd indices. Your task is to find the maximum alternating sum of any subsequence formed by deleting some elements from the array without changing the relative order of the remaining elements.
Given an integer array nums, your goal is to select four distinct indices w, x, y, and z such that the product difference between two pairs of numbers, (nums[w], nums[x]) and (nums[y], nums[z]), is maximized. The product difference is defined as (nums[w] * nums[x]) - (nums[y] * nums[z]). Return the maximum product difference between these two pairs.
You are given an m x n integer matrix grid, where both m and n are even integers, and an integer k. The matrix consists of several concentric layers, and each layer can be thought of as a circular band of numbers. A cyclic rotation of a layer is done by shifting all its elements counter-clockwise by one position. You are asked to return the matrix after applying k cyclic rotations to each of its layers.
Given a zero-based permutation nums (0-indexed), build a new array ans of the same length where for each i, ans[i] = nums[nums[i]]. Return the array ans. A zero-based permutation means that the array consists of distinct integers from 0 to nums.length - 1 (inclusive).
You are defending your city from a group of n monsters. You are given two arrays dist and speed, where dist[i] is the initial distance of the ith monster from the city, and speed[i] is the speed of the ith monster in kilometers per minute. Your weapon takes one minute to charge and can eliminate one monster once fully charged. The game ends if any monster reaches the city before your weapon is ready. Return the maximum number of monsters you can eliminate or n if all monsters can be eliminated before they reach the city.