Given a positive integer n, you need to construct an array called powers that contains the minimum number of powers of 2 that sum up to n. The array powers should be sorted in non-decreasing order. You are also given a set of queries where each query asks for the product of the powers in the powers array between indices left and right (both inclusive). For each query, return the product modulo 10^9 + 7.
You are given a 0-indexed array nums of length n, where each element represents the number of items in a container. In one operation, you can pick an index i such that 1 <= i < n and nums[i] > 0, and move one item from nums[i] to nums[i-1]. Your goal is to minimize the maximum value in the array nums after performing any number of operations.
You are given a string representing the log of a shop’s customer visits over a series of hours. Each character in the string is either ‘Y’ (customer visits) or ‘N’ (no customer visits). The shop can close at any given hour, and the penalty is determined by two factors: when the shop is open but no customers visit, and when the shop is closed but customers still arrive. You need to determine the earliest hour at which the shop should close to minimize the penalty.
Given a positive integer n, you are tasked with finding an integer x such that the sum of all integers from 1 to x is equal to the sum of all integers from x to n, inclusive. If no such integer exists, return -1. It is guaranteed that there will be at most one solution for the given input.
You are given a positive integer n representing the size of an n x n matrix initially filled with zeros, and a 2D integer array queries. Each query consists of four integers [row1, col1, row2, col2]. For each query, add 1 to every element in the submatrix from (row1, col1) to (row2, col2) in the matrix. Return the matrix after applying all queries.
Given an array of strings words and a list of queries, each query asks to count the number of strings in the specified range that start and end with a vowel. The vowels are ‘a’, ’e’, ‘i’, ‘o’, and ‘u’.