You are given an integer array nums of length n and an integer array queries of length m. For each query, return the maximum size of a subsequence that can be selected from nums such that the sum of its elements is less than or equal to the query value. A subsequence is derived by deleting some or no elements from the array while keeping the relative order intact.
You are given an array of strings garbage where each string represents the garbage collected at a specific house. The characters ‘M’, ‘P’, and ‘G’ represent metal, paper, and glass garbage, respectively. The time to collect one unit of garbage is 1 minute. You are also given an array travel where each element represents the time required to travel between two consecutive houses. Three trucks are responsible for picking up different types of garbage and can only travel sequentially from house 0 to the end. Each truck only collects one type of garbage and each truck can only be used one at a time. Return the minimum time required to pick up all the garbage.
You are given a 0-indexed integer array nums. Your task is to determine if there are two subarrays of length 2 that have the same sum, but these subarrays must begin at different indices in the array. A subarray is defined as a contiguous sequence of elements within the array.
You are given a binary matrix matrix of size m x n and an integer numSelect. Your goal is to select exactly numSelect distinct columns from the matrix such that you cover as many rows as possible. A row is considered covered if all the 1’s in that row are included in the selected columns. If a row has no 1’s, it is also considered covered.
You are given a string s consisting of lowercase English letters where each letter appears exactly twice. You are also given an array distance of length 26, where each element represents the number of characters between the two occurrences of the corresponding letter (0-indexed, ‘a’ corresponds to index 0, ‘b’ to index 1, etc.). Your task is to determine if the string s is a ‘well-spaced’ string. A string is well-spaced if, for each letter in s, the number of characters between its two occurrences matches the corresponding value in the distance array.
You are given an array nums consisting of positive integers. A subarray of nums is considered nice if the bitwise AND of every pair of elements, that are at different positions in the subarray, is equal to 0. Your task is to return the length of the longest nice subarray. A subarray is a contiguous part of an array, and subarrays of length 1 are always considered nice.