You are given two integers: numBottles, representing the number of full water bottles you initially have, and numExchange, representing the number of empty bottles required to exchange for a full bottle. In one operation, you can drink any number of full water bottles, turning them into empty bottles, or exchange numExchange empty bottles for one full bottle, with numExchange increasing by 1 after each exchange. Return the maximum number of water bottles you can drink.
You are given a binary array nums. A subarray is called alternating if no two adjacent elements in the subarray have the same value. Return the total number of alternating subarrays in the given binary array.
You are given a 2D binary matrix grid, where each element is either 0 or 1. A collection of three elements of the grid is considered a right triangle if one element lies in the same row as another and in the same column as the third. The three elements must not be adjacent to each other. Your task is to count the number of right triangles that can be formed where all three elements have a value of 1.
You are given two positive integers, n and k. There are n children numbered from 0 to n - 1, standing in a queue from left to right. Initially, child 0 holds a ball and the direction of passing the ball is towards the right. After each second, the child holding the ball passes it to the next child in the queue. If the ball reaches the first or last child, the direction of passing the ball reverses. You need to determine which child will have the ball after k seconds.
You are given two integers, n and k. Initially, you have an array a of size n, where each element is initialized to 1. After each second, every element in the array is updated to be the sum of all preceding elements plus the element itself. The process repeats for k seconds. You need to return the value of the last element of the array, a[n - 1], after k seconds. Since the result may be very large, return it modulo (10^9 + 7).
You are given an array of integers nums. In each operation, you can either add or subtract 1 from any element in nums. Your task is to determine the minimum number of operations required to make all elements of nums divisible by 3.