You are given an integer money and an integer children. You need to distribute the money to the children such that everyone gets at least 1 dollar, nobody gets exactly 4 dollars, and you maximize the number of children receiving exactly 8 dollars. Return the maximum number of children who receive 8 dollars, or -1 if it’s not possible.
Given a positive integer n, return an array containing the number of 1 bits at even indices and odd indices in the binary representation of n. The binary digits are indexed from right to left, starting at index 0. The first element of the array should represent the number of 1 bits at even indices, and the second element should represent the number of 1 bits at odd indices.
You are given a bag with items, where each item has a number written on it, which could be 1, 0, or -1. You are also given the counts of items with 1s, 0s, and -1s, as well as a positive integer k. Your task is to pick exactly k items from the bag, maximizing the sum of the numbers written on the selected items.
You are given two arrays nums1 and nums2, both containing unique digits. Your task is to find the smallest possible number that contains at least one digit from both arrays. If there are common digits between the two arrays, the smallest common digit will be the answer. If no common digit exists, return the smallest number formed by taking the smallest digit from each array.
You are given a binary string consisting of only ‘0’s and ‘1’s. A substring of this binary string is considered balanced if it contains equal numbers of ‘0’s and ‘1’s, and all the ‘0’s come before the ‘1’s. Your task is to find the length of the longest balanced substring.
Given a 2D grid of integers, you need to determine the largest prime number present on any of the diagonals of the grid. A number is considered prime if it is greater than 1 and divisible only by 1 and itself. The diagonal elements are those where the row and column indices are the same or sum to the length of the grid minus 1.