You are standing at a starting position startPos on an infinite number line, and you need to reach a destination endPos in exactly k steps. In each step, you can move either one position to the left or one position to the right. Your task is to find the number of different ways to reach endPos from startPos in exactly k steps. Since the number of ways can be very large, return the result modulo 10^9 + 7.
You are given an array of positive integers nums and a positive integer k. A subset of nums is considered beautiful if it does not contain any two integers whose absolute difference is equal to k. Your task is to return the number of non-empty beautiful subsets of the array nums. A subset is formed by deleting some (possibly none) elements from nums, and two subsets are different if their selected indices are different.
You are given two positive integers, ’n’ (number of candies) and ’limit’ (maximum number of candies each child can receive). Your task is to calculate how many different ways you can distribute ’n’ candies among 3 children such that no child receives more than ’limit’ candies.
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 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).